I'm creating an EventHub client application that sends message to an Event Hub on Azure.
Now when I have a message to send (every 5-6 seconds) I create a new instance of the class EventHubClient, then I use it to send data:
public async static void SendListOfMeasurements(string eventHubName, string connectionString, List<Measurement> measurementsList, int maxMessageSize)
// Create EventHubClient
EventHubClient client = EventHubClient.CreateFromConnectionString(
No, It's necessary to create a new EventHubClient using the MessageFactory only the first time. If I create a Client for every message I send, then a new connection is created and the old one remain opened (checked using netstat) resulting in a lot of "ESTABILISHED" connections.
Using a single client created for the first message, then recycling the client for the other messages, if the internet connection is lost then comes back, the tcp connection is automatically re-created.