Arun S Krishnan
Arun S Krishnan

Reputation: 73

Service bus connection is not working from on-premise console application

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)

Upvotes: 6

Views: 12504

Answers (1)

Jesse Squire
Jesse Squire

Reputation: 7860

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.

Upvotes: 13

Related Questions