Share via

Eventhub(java) issue while posting message from on premises through proxy

mohammed farooq 1 Reputation point
2020-03-05T21:45:54.19+00:00

I have a requirement to send messages from on premises to Event hub thru proxy,

I am using java and getting an exception

Created Eventhub was enabled for all networks.

Followed the link : https://techcommunity.microsoft.com/t5/event-hubs-blog/azure-event-hubs-websockets-and-proxy-support/ba-p/371136

Any help on this please

maven dependency :

<dependency>  
   <groupId>com.microsoft.azure</groupId>  
     <artifactId>azure-eventhubs</artifactId>  
    <version>3.0.0</version>  
</dependency>  


public static void main(String[] args)  
            throws EventHubException, ExecutionException, InterruptedException, IOException {  
    final ConnectionStringBuilder connectionStringBuilder = new ConnectionStringBuilder()  
            .setNamespaceName("myeventhubnamespace")  
            .setEventHubName("myeventhubname")  
            .setSasKeyName("RootManageSharedAccessKey")  
            .setSasKey("xxxxxxxxxxxxxxxxx");  
      
    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("xxx.xxxx.xxxx", 8085)));  
    return proxies;  
        }  
    @Override  
        public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {  
    // trace and follow up on why proxy server is down  
        }  
    });  
    // step-2: configure EventHubClient transport to AmqpWebSockets  
    connectionStringBuilder.setTransportType(TransportType.AMQP_WEB_SOCKETS);  
      
      
    // step-2: configure EventHubClient transport to AmqpWebSockets  
    ScheduledExecutorService executorService = null;  
    try {  
        executorService = Executors.newScheduledThreadPool(1);  
        EventHubClient ehClient = EventHubClient.createSync(connectionStringBuilder.toString(), executorService);  
        ehClient.sendSync(EventData.create("Test Message".getBytes()));  
    }finally {  
        executorService.shutdown();  
    }  
      
    }  

Exception stacktrace

Exception in thread "main" com.microsoft.azure.eventhubs.EventHubException: org.apache.qpid.proton.engine.TransportException: proxy connect request failed with error: HTTP/1.0 200 Connection established  
	at com.microsoft.azure.eventhubs.impl.ExceptionUtil.toException(ExceptionUtil.java:60)  
	at com.microsoft.azure.eventhubs.impl.MessagingFactory.onConnectionError(MessagingFactory.java:264)  
	at com.microsoft.azure.eventhubs.impl.ConnectionHandler.onTransportError(ConnectionHandler.java:171)  
	at org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:191)  
	at org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)  
	at org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:324)  
	at org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:291)  
	at com.microsoft.azure.eventhubs.impl.MessagingFactory$RunReactor.run(MessagingFactory.java:490)  
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)  
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)  
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)  
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)  
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
	at java.lang.Thread.run(Thread.java:745)  
Azure Service Fabric
Azure Service Fabric

An Azure service that is used to develop microservices and orchestrate containers on Windows and Linux.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Msc ti 1 Reputation point
    2020-06-28T23:28:43.827+00:00

    Exception in thread "main" com.microsoft.azure.eventhubs.EventHubException: org.apache.qpid.proton.engine.TransportException: proxy connect request failed with error: HTTP/1.0 200 Connection established
    at com.microsoft.azure.eventhubs.impl.ExceptionUtil.toException(ExceptionUtil.java:60)
    at com.microsoft.azure.eventhubs.impl.MessagingFactory.onConnectionError(MessagingFactory.java:264)
    at com.microsoft.azure.eventhubs.impl.ConnectionHandler.onTransportError(ConnectionHandler.java:171)
    at org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:191)
    at org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)
    at org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:324)
    at org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:291)
    at com.microsoft.azure.eventhubs.impl.MessagingFactory$RunReactor.run(MessagingFactory.java:490)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

    Was this answer helpful?

    0 comments No comments

  2. Anand Vara 1 Reputation point
    2020-06-01T06:09:09.363+00:00

    Are you able to solve this issue? Please post the solution if its resolved.

    Was this answer helpful?

    0 comments No comments

  3. jakaruna-MSFT 601 Reputation points Microsoft Employee Moderator
    2020-03-24T14:32:11.427+00:00

    If your issue is not resolved till now, Please send your subscription id to this email azcommunity@microsoft.com.

    I will help you to enable a one time free support ticket for you.

    In the email subject add "for jakaruna-msft <this questions title>" and add this questions url in the email body.

    Once your issue is resolved, you can post the answer here.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.