Shubha Vijayasarathy - I am getting CommunicationException when I tried to implement EventHub Publish with Proxy settings.
EventHub SDK Version - com.microsoft.azure:azure-eventhubs:3.2.2
Below is the Implementation details:
public void sendEvent(VinData vinData) throws EventHubException, ExecutionException, InterruptedException, IOException{
// step-1: set the proxy server settings
ProxySelector.setDefault(new ProxySelector() {
@Override
public List<Proxy> select(URI uri) {
LinkedList<Proxy> proxies = new LinkedList<>();
proxies.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("19.12.64.237", 83)));
proxies.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("19.12.80.237", 83)));
proxies.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("19.12.16.64", 83)));
proxies.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("19.12.32.11", 83)));
return proxies;
}
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
// trace and follow up on why proxy server is down
}
});
ScheduledExecutorService executorService1 = Executors.newScheduledThreadPool(5);
EventHubClient evHubClient = EventHubClient.createFromConnectionStringSync(new ConnectionStringBuilder(config.getFfmEvHubConnectionString())
.setTransportType(TransportType.AMQP_WEB_SOCKETS).toString(),
executorService1);
log.info("#VinData ==> "+vinData.getBody().getVin());
log.info("#ProxyConfig Configured? =>"+proxyConfig1.isProxyAddressConfigured());
log.info("#Proxy Config ==> Address ==> "+proxyConfig1.proxyAddress().address());
try {
log.info("VinData ==> "+vinData.getBody().getVin());
byte[] bytes = SerializationUtils.serialize(vinData);
log.info("Sending message from FFM VInData to the event hub {}", config.getFfmEvHubName());
EventData ffmEventData = EventData.create(bytes);
log.info("FFM Event Data ::"+ffmEventData.toString());
√.sendSync(ffmEventData);
}finally {
evHubClient.closeSync();
//executorService.shutdown();
}
}
The above code execution is throwing the below mentioned exception:
2021-08-13T14:23:23.279+05:30 [APP/PROC/WEB/0] [OUT] 2021-08-13 08:53:23.279 ERROR [cdr-service-eventhubsimulator,39eda51eabe4e7a8,39eda51eabe4e7a8,true] 21 --- [nio-8080-exec-8] c.f.c.e.controller.EventhubController : An error arose sending a message to event hub: com.microsoft.azure.eventhubs.CommunicationException: A communication error has occurred. This may be due to an incorrect host name in your connection string or a problem with your network connection.
2021-08-13T14:23:23.280+05:30 [APP/PROC/WEB/0] [ERR] com.microsoft.azure.eventhubs.CommunicationException: A communication error has occurred. This may be due to an incorrect host name in your connection string or a problem with your network connection.
2021-08-13T14:23:23.280+05:30 [APP/PROC/WEB/0] [ERR] at com.microsoft.azure.eventhubs.impl.ExceptionUtil.toException(ExceptionUtil.java:71)
2021-08-13T14:23:23.280+05:30 [APP/PROC/WEB/0] [ERR] at com.microsoft.azure.eventhubs.impl.MessagingFactory.onConnectionError(MessagingFactory.java:525)
2021-08-13T14:23:23.280+05:30 [APP/PROC/WEB/0] [ERR] at com.microsoft.azure.eventhubs.impl.ConnectionHandler.onTransportError(ConnectionHandler.java:220)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:191)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:324)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:291)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at com.microsoft.azure.eventhubs.impl.MessagingFactory$RunReactor.run(MessagingFactory.java:784)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
2021-08-13T14:23:23.281+05:30 [APP/PROC/WEB/0] [ERR] at java.base/java.lang.Thread.run(Unknown Source)
2021-08-13T14:23:23.283+05:30 [APP/PROC/WEB/0] [OUT] 2021-08-13 08:53:23.283 DEBUG [cdr-service-eventhubsimulator,39eda51eabe4e7a8,39eda51eabe4e7a8,true] 21 --- [nio-8080-exec-8] o.s.w.s.m.m.a.HttpEntityMethodProcessor : No match for [*/*], supported: []
2021-08-13T14:23:23.284+05:30 [APP/PROC/WEB/0] [OUT] 2021-08-13 08:53:23.284 DEBUG [cdr-service-eventhubsimulator,39eda51eabe4e7a8,39eda51eabe4e7a8,true] 21 --- [nio-8080-exec-8] o.s.web.servlet.DispatcherServlet : Completed 500 INTERNAL_SERVER_ERROR
Can anyone help me resolve this issue.
Also how do we make sure the EventHubClient object is using ProxyDetails to publish the data?