Skip to content

feat: Add WebSocket transport support for AMQP 1.0 connections#78

Merged
Gsantomaggio merged 2 commits intorabbitmq:mainfrom
vedanthnyk25:main
Jan 21, 2026
Merged

feat: Add WebSocket transport support for AMQP 1.0 connections#78
Gsantomaggio merged 2 commits intorabbitmq:mainfrom
vedanthnyk25:main

Conversation

@vedanthnyk25
Copy link
Copy Markdown
Contributor

@vedanthnyk25 vedanthnyk25 commented Jan 19, 2026

This PR adds support for connecting to RabbitMQ via WebSockets (ws:// and wss:// schemes). This is essential for environments where direct TCP access (ports 5672/5671) is restricted by firewalls, allowing connection via standard HTTP/HTTPS ports.

Changes:

  • transport_websocket.go: Added a net.Conn adapter that wraps gorilla/websocket connections, making them compatible with the go-amqp library.

  • amqp_connection.go: Updated Dial logic to detect ws/wss schemes. It automatically handles the HTTP upgrade and passes the connection to the AMQP client.

  • uri.go: Updated validation logic to accept ws and wss as valid schemes.

-URL Sanitization: Added logic to move User/Password from the URL to Basic Auth headers, as required by the WebSocket handshake.

Testing:

  • Verified against a local RabbitMQ instance using websockify proxy (simulating a production NGINX/Envoy termination).

  • Ran existing regression tests (make test).

Screenshot from 2026-01-20 00-16-10

If any changes are required, please let me know.
Closes #74

@Gsantomaggio Gsantomaggio self-assigned this Jan 21, 2026
@Gsantomaggio Gsantomaggio merged commit 49f214f into rabbitmq:main Jan 21, 2026
2 checks passed
@Gsantomaggio
Copy link
Copy Markdown
Member

Thanks a lot, @vedanthnyk25.
The PR requires a bit of work, but I'll do that. Going to merge!

@vedanthnyk25
Copy link
Copy Markdown
Contributor Author

Thank you so much, @Gsantomaggio !
I really appreciate you taking the time to review and merge this. I’m eager to see your follow-up commits so I can learn what I missed for next time. Happy to contribute again in the future.

@Gsantomaggio
Copy link
Copy Markdown
Member

@vedanthnyk25 Thank you. Please see: #79
had to add: sec-websocket-protocol: amqp ref: https://www.rfc-editor.org/rfc/rfc6455.html

Gsantomaggio added a commit that referenced this pull request Jan 21, 2026
This pull request adds support for the AMQP WebSocket subprotocol by including the `Sec-WebSocket-Protocol` header in WebSocket connections, and provides a complete example demonstrating AMQP 1.0 over WebSockets.

**Changes:**
- Added `Sec-WebSocket-Protocol: amqp` header to WebSocket connection initialization
- Created a comprehensive WebSocket example with queue declaration, message publishing, and consumption
- Added documentation for setting up and running the WebSocket example

Complete: #78
---------

Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
@Gsantomaggio Gsantomaggio added the enhancement New feature or request label Jan 21, 2026
@Gsantomaggio Gsantomaggio added this to the 0.5.0 milestone Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support AMQP over WebSockets

2 participants