Tuesday, May 24, 2022

Azure @ Enterprise - Disable AMQP over 5671 to use Websocket

Till today, my experience with Azure ServiceBus¹ is really good. Apps are running well in production that uses ServiceBus. One of the issues we faced is detailed in this blog post. It is nothing with the Azure but due to the stringent enterprise networking  

Problem

The application that consumes Azure ServiceBus works excellent in all the lower environments but not in the client's production environment. In production, it's not able to establish connectivity. All the required ports (5671 and 443) are open, and credentials are in place. Still, it is not able to communicate. 

Root cause

Since it works outside the enterprise environment, we are sure it's nothing with the code. Somewhere in the enterprise network, one of the devices doesn't like the plain AMQP² traffic going through it targeting port 5671³.

What is AMQP?

The 'Advanced Message Queuing Protocol' is the standard for messaging. It works cross-platform than vendor-specific protocols that existed prior to the adoption of AMQP.

Solution

Do not use plain AMQP targeting port 5671, instead use AMQP over Websockets that use port 443. 

By default, the .Net SDK for Azure ServiceBus uses AMQP over 5671. But there are mainly 2 ways to change the behavior.

Using the code switch

This is a coded solution where we have to change the transport type to AmqpWebSockers. Its as follows from .Net

The above sample uses the latest nuget SDK (Azure.Messaging.ServiceBus) as of this writing. There are legacy SDKs and the code will be slightly different than this. Similarly, we can control this from the non .Net SDKs as well.

Using the connection string

The second method is to construct a connection string that indicates the use of the Amqp over web sockets. Since it is straightforward details are omitted.

References

No comments: