locked
Issue with Azure Eventhub (java) using proxy RRS feed

  • Question

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

    I am using java  and getting an exception 

    Followed the link on microsoft tech community(cant paste full link as it blocks) :  /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)

    Friday, February 21, 2020 5:09 PM

Answers