“Could not connect to net.tcp://XXXXX.servicebus.windows.net:9354/. The connection attempt lasted for a time span of 00:00:21.0254249. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 188.8.131.52:9354.“
After some investigation, I figured out that the issue was due to change in environment. When I had initially developed the application, I was working on a network which had no restrictions. But my demo was on my office network that had a firewall with ports locked down. To communicate with the ServiceBus, the SDK uses tcp port 9354.
You can open this port and make the application work. Or if you are going to run your application in an environment where IT will not open ports for your application, you can communicate with the ServiceBus using HTTP.
To communicate using HTTP, before you perform any operations, set the connectivity mode to http.
Microsoft.ServiceBus.ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;
This mode setting applies to all endpoints being used by your application.
Using Http mode has a performance downside compared to Tcp. I will update this post soon with some performance numbers comparing the 2 modes.