title: Getting connection closed exception while inserting messages to Evenhub using its client
body: <p>I m basically using java to insert streaming data into the event hub. I am using the EventHubProducerClient to insert the same. But I am seeing some loss of messages while insertion and I see the below amqp exception while insertion</p>
  <pre><code>```
  EventHubProducerClient client = new EventHubClientBuilder().connectionString(connectionString, eventHubName)
                  .buildProducerClient();
          try {
              EventDataBatch dataBatch = client.createBatch();
              EventData data = new EventData(content);
              if (null != data &amp;&amp; dataBatch.tryAdd(data)) {
                  client.send(dataBatch);
                  LOG.info(&quot;Message Sent to Eventhub&quot;);
                  client.close();
              } else
                  System.out.println(&quot;The data getting passed is null&quot;);
          } catch (IllegalArgumentException e) {
              e.printStackTrace();
              telemetryClient.trackException(e);
          } catch (AmqpException e) {
              e.printStackTrace();
              telemetryClient.trackException(e);
          } catch (IOException e) {
              e.printStackTrace();
              telemetryClient.trackException(e);
          } catch (Exception e) {
              e.printStackTrace();
              telemetryClient.trackException(e);
          } finally {
              client.close();
          }
  ```
  </code></pre>
  <p>But I am seeing loss of some messages from source to Eventhub. In my application logs I see the following exception displaying once in every two days</p>
  <pre><code>**connectionId[MF_9ac2be_1645071417683] Connection closed. Could not get active connection., errorContext[NAMESPACE: Eventhub_Name.servicebus.windows.net]**
  
  Full Exception stacktrace :
  ```
  com.azure.core.amqp.exception.AmqpException:
     at com.azure.core.amqp.implementation.ReactorConnection.onClosedError (ReactorConnection.java:400)
     at com.azure.core.amqp.implementation.ReactorConnection.&lt;init&gt; (ReactorConnection.java:116)
     at com.azure.messaging.eventhubs.implementation.EventHubReactorAmqpConnection.&lt;init&gt; (EventHubReactorAmqpConnection.java:64)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.lambda$buildConnectionProcessor$0 (EventHubClientBuilder.java:643)
     at reactor.core.publisher.FluxCreate$BaseSink.onRequest (FluxCreate.java:536)
     at reactor.core.publisher.FluxCreate$SerializedFluxSink.onRequest (FluxCreate.java:264)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.lambda$buildConnectionProcessor$1 (EventHubClientBuilder.java:624)
     at reactor.core.publisher.FluxCreate.subscribe (FluxCreate.java:94)
     at reactor.core.publisher.Flux.subscribe (Flux.java:8156)
     at reactor.core.publisher.Flux.subscribeWith (Flux.java:8329)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.buildConnectionProcessor (EventHubClientBuilder.java:651)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.buildAsyncClient (EventHubClientBuilder.java:555)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.buildClient (EventHubClientBuilder.java:593)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.buildProducerClient (EventHubClientBuilder.java:501)
     at com.xxx.EventHubConnector.publishEvents (EventHubConnector.java:30)   
  ```
  </code></pre>
  <p>Why am I seeing the above error ? I know I am closing the eventhub client twice but I guess it should not cause the issue. Please correct me if I am wrong</p>
  <p>Adding Full Exception stacktrace :</p>
  <pre><code> com.azure.core.amqp.exception.AmqpException:
     at com.azure.core.amqp.implementation.ReactorConnection.onClosedError (ReactorConnection.java:400)
     at com.azure.core.amqp.implementation.ReactorConnection.&lt;init&gt; (ReactorConnection.java:116)
     at com.azure.messaging.eventhubs.implementation.EventHubReactorAmqpConnection.&lt;init&gt; (EventHubReactorAmqpConnection.java:64)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.lambda$buildConnectionProcessor$0 (EventHubClientBuilder.java:643)
     at reactor.core.publisher.FluxCreate$BaseSink.onRequest (FluxCreate.java:536)
     at reactor.core.publisher.FluxCreate$SerializedFluxSink.onRequest (FluxCreate.java:264)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.lambda$buildConnectionProcessor$1 (EventHubClientBuilder.java:624)
     at reactor.core.publisher.FluxCreate.subscribe (FluxCreate.java:94)
     at reactor.core.publisher.Flux.subscribe (Flux.java:8156)
     at reactor.core.publisher.Flux.subscribeWith (Flux.java:8329)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.buildConnectionProcessor (EventHubClientBuilder.java:651)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.buildAsyncClient (EventHubClientBuilder.java:555)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.buildClient (EventHubClientBuilder.java:593)
     at com.azure.messaging.eventhubs.EventHubClientBuilder.buildProducerClient (EventHubClientBuilder.java:501)
     at com.swinds.connectors.EventHubConnector.publishEvents (EventHubConnector.java:30)
     at com.swinds.connectors.EventHubConnector.setEventHub (EventHubConnector.java:77)
     at com.swinds.connectors.EventHubConnector.routeEventHub (EventHubConnector.java:66)
     at com.swinds.function.BlobFunction.run (BlobFunction.java:17)
     at sun.reflect.GeneratedMethodAccessor3.invoke
     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke (Method.java:498)
     at com.microsoft.azure.functions.worker.broker.JavaMethodInvokeInfo.invoke (JavaMethodInvokeInfo.java:22)
     at com.microsoft.azure.functions.worker.broker.JavaMethodExecutorImpl.execute (JavaMethodExecutorImpl.java:54)
     at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod (JavaFunctionBroker.java:57)
     at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute (InvocationRequestHandler.java:33)
     at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute (InvocationRequestHandler.java:10)
     at com.microsoft.azure.functions.worker.handler.MessageHandler.handle (MessageHandler.java:45)
     at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0 (JavaWorkerClient.java:92)
     at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
     at java.util.concurrent.FutureTask.run (FutureTask.java:266)
     at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
     at java.lang.Thread.run (Thread.java:748)
  </code></pre>