Magnus Gladh
Magnus Gladh

Reputation: 1937

Azure service bus, long time to create a client

I am playing around with Azure Services Bus trying to do some Publish/Subscription. Everything works as it should but when I am trying to create a client from a connectionstring it takes really long time to do the connection. It takes around 22 seconds, to create a client.

this is how it's done.

var subscriptionClient1 = SubscriptionClient.CreateFromConnectionString(_connectionstring, "testTopic", "testSubscription");

When that first connection is made it's fast it takes 2ms to create a new client. So I guess most of the time is to create a connection to azure and verify the security context.

My question is, is it that slow for everybody else? (if not then I guess it's our network setup that makes it slow) Is there another way to do the connection and creation of clients that might be faster?

Best regards Magnus

Upvotes: 0

Views: 581

Answers (2)

pseabury
pseabury

Reputation: 1735

I haven't looked at the ServiceBus SubscriptionClient code (if it's available on GitHub), but the long delay is definitely related to the ConnectivityMode and fallback mechanism on networks that cannot use the normal Tcp transport. The probe/fallback to https takes about 20s.

If I manually tell Servicebus to use Https (i.e. to avoid the AutoDetect fallback) on installations where I know all I have is Https, then I get about 1 second for each SubscriptionClient. I think the transport selection mechanism in the client could probably be a little faster. Anyway, here's how:

ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Https;

I use an AppSetting to control this manually for now.

Upvotes: 1

Magnus Gladh
Magnus Gladh

Reputation: 1937

I have tried to do the connection from home, and it took only 1-2 seconds instead of the 22 from work. So I guess there is something in the works networks setup that is the cause to the slow connection.

I have told the infrastructure guys at work and hope the find the reason why. If they can't well then it's not something that we can use. Even if it's faster after the first connect, it still takes 22 seconds for the first one, and that is simple way to long time.

Upvotes: 0

Related Questions