6

I have created a .net core 3.1 console application for reading azure service bus queue messages and deployed the EXE in a client on-premise VM. It was working initially but now it is not working from VM (now also working from local machine). I am getting a time-out (socket exception) while executing the exe in on-premise VM. I am using shared access policy connection strung to connect the service bus.

Exception : Azure.Messaging.ServiceBus.ServiceBusException: 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. ErrorCode: TimedOut (ServiceCommunicationProblem) ---> System.Net.Sockets.SocketException (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. at Microsoft.Azure.Amqp.Transport.TransportStream.EndRead(IAsyncResult asyncResult) at Microsoft.Azure.Amqp.Transport.TransportStream.<>c__DisplayClass22_0.b__1(IAsyncResult a) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

1 Answers1

10

The most common connection issue in an enterprise environment is that the ports needed for AMQP over TCP (5671/5672) are not open. Changing the transport to AMQP over WebSockets often helps, as it will use port 443 and may be routed through a proxy, if needed.

Both the transport and the proxy (if needed) can be specified using the ServiceBusClientOptions when creating your client:

var options = new ServiceBusClientOptions
(
    TransportType = ServiceBusTransportType.AmqpWebSockets,
    WebProxy = new WebProxy("https://proxyserver:80", true)
};
    
var client = new ServiceBusClient("<< CONNECTION STRING >>", options);

For more information, you may want to look at the Service Bus troubleshooting guide.

Jesse Squire
  • 6,107
  • 1
  • 27
  • 30
  • This is like the only reference I can find to this issue, even that troubleshooting guide starts and stops at this mention. I have tested and verified that these TCP values are valid and working and am now left with no next step. – Captain Prinny Jan 26 '22 at 17:51
  • Unfortunately, these errors occur within the network stack for the .NET runtime or host OS, so there's little insight or influence that the SDK has into the deeper meaning. Because network configurations are unique and we can't know the specifics of what hardware is in use and how they're configured, it's very difficult to generalize. Your best path forward would likely be to work with your network admin or ISP to better understand the configuration of the local network and whether your SB namespace is using Private Link to restrict access. – Jesse Squire Jan 26 '22 at 20:36