Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

AMQP connection still alive even if EventHubClient closed

$
0
0

Hello,

"playing" with event hub (using last Azure SDK 2.6.0), I discovered a strange thing ...

I use event hub with AMQP as underlying protocol (using TransportType.Amqp) that as we know needs : a connection to the service bus namespace, a session inside the connection and a link to the entity (an event hub in this case).

The connection is handled by the MessagingFactory instance so if I create an EventHubClient from a factory and an EventHubSender from the same client, the TCP connection is closed using factory.Close() method. The Close() methods called on the client and on the sender close only session/link to the entity but not the connection.

In the following code, I create a factory, a client from the factory and a sender from the client. Using Wireshark I see the TCP handshake for opening connection, encrypted traffic on transferring data and a final TCP closing connection (when factory.Close() is called).

string connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            ServiceBusConnectionStringBuilder builder = new ServiceBusConnectionStringBuilder(connectionString);
            builder.TransportType = TransportType.Amqp;

            MessagingFactory factory = MessagingFactory.CreateFromConnectionString(builder.ToString());

            EventHubClient client = factory.CreateEventHubClient("ppatiernoeventhub");
            EventData data = new EventData(Encoding.UTF8.GetBytes("Hello"));
            client.Send(data);
            client.Close();

            EventHubSender sender = client.CreatePartitionedSender("0");
            data = new EventData(Encoding.UTF8.GetBytes("Hello"));
            sender.Send(data);
            sender.Close();

            factory.Close();

The above code works fine as I expect but ...

If I create an EventHubClient using the static method CreateFromConnectionString(), I haven't a reference to the internal used MessagingFactory so when I call client.Close() method, using Wireshark I see some encrypted traffic related to the session/link close but there isn't the TCP closing connection (exchange of FYN, FYN-ACK, ACK on both sides).

EventHubClient client2 = EventHubClient.CreateFromConnectionString(builder.ToString(), "ppatiernoeventhub");
            data = new EventData(Encoding.UTF8.GetBytes("Hello"));
            client2.Send(data);
            client2.Close();
 

It means that the TCP connection with service bus (not the session/link with the entity) is still opened.

How we can close it as in the case of factory.Close() ?

Thanks,

Paolo.


Paolo Patierno


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>