0

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

Magnus Gladh
  • 1,817
  • 4
  • 20
  • 31
  • 1
    What data center are you connecting and have you tried other ones? – Sean Feldman May 29 '17 at 14:50
  • I have checked my creation of SubscriptionClient, it costs me 7 seconds at the first time. I checked the Microsoft.ServiceBus.dll and found the client would cache the connection, so the latter creation of a new client would be faster. – Bruce Chen May 30 '17 at 03:45
  • I've found the exact same 21-22 seconds to create a SubscriptionClient with the same line of code that you are. I use the two closest datacenters with the same result. I know I'm on a restrictive network, and I might be limited to http/s transport by their firewalls. I'm still not convinced it should take so long though. – pseabury Feb 22 '18 at 02:54
  • @SeanFeldman - Is this something that can be improved in the Auto-detect code for the client (i.e. can the regular tcp transports fail faster to http/s is that's all that's available)? – pseabury Feb 23 '18 at 15:16
  • Perhaps. This is closed source client, so the best option is to raise an issue [here](https://github.com/Azure/azure-service-bus/issues). – Sean Feldman Feb 23 '18 at 17:31

2 Answers2

1

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.

pseabury
  • 1,615
  • 3
  • 16
  • 30
0

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.

Magnus Gladh
  • 1,817
  • 4
  • 20
  • 31