Search code examples
spring-bootazureservicebusamqpqpid

Connecting to azure service bus port 443 with amqpwss using apache qpid


I'm trying to connect to an Azure Service bus using amqp-10-jms-spring-boot starter (which I understand to use apache qpid jms under the hood.

When I set the connection string (amqphub.amqp10jms.remote-url) to use 'amqps://' everything works fine, a hello world message is sent to an Azure queue and then retreived & printed by the application.

However when I use an "amqpwss://[Endpoint]:443" connection string I receive an exception...

Caused by: io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 400 This service does not support WebSocket connections.

I am skeptical that the Azure Service bus does not support WebSocket connections.

  1. The amqphub documentation claims this is possible: https://github.com/amqphub/amqp-10-jms-spring-boot#jms-connection-configuration
  2. As does the apache quid documentation: http://qpid.apache.org/releases/qpid-jms-0.52.0/docs/index.html
  3. As does the Service bus documentation "The AMQP WebSockets binding creates a tunnel over TCP port 443 that is then equivalent to AMQP 5671 connections.": https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-protocol-guide#connections-and-sessions

How can I establish an amqpwss connection to an Azure service bus from a Spring Boot Application? (I would like to use qpid but I'm not tied to it).

Sample code here: https://github.com/kevvvvyp/amqp-websocket-apache-qpid


Solution

  • After a support attempt at getting upselled, and looking through the documentation again I've proven once again that microsoft is aggressively interested in embracing and vendor locking people into their garden.

    Tirade aside, the URL to connect to websockets endpoint is different compared to regular AMQP endpoint. Suppose you have the following

    amqps://[endpoint]
    

    To connect using websockets, you'd replace the protocol with amqpwss and the port with 443

    amqpwss://[endpoint]:443
    

    But, what is not mentioned, is that you must also specify a path of /$servicebus/websocket. As a result, the final url is

    amqpwss://[endpoint]:443/$servicebus/websocket
    

    I have no clue how you're supposed to figure this out. Please prove me wrong and point to the bit in documentation that as of 2021-03-18 does contain this bit of information. Regardless, I found it out via this SO question regarding connecting from browser via websockets to azure service bus.