-
Notifications
You must be signed in to change notification settings - Fork 4k
Support mqttv3.1 WebSocket subprotocol in addition to mqtt
#15008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Addresses rabbitmq#15001 The Web MQTT handler only accepts the `mqtt` WebSocket subprotocol, rejecting clients that request `mqttv3.1`. This prevents some MQTT clients from establishing WebSocket connections. This change updates the protocol negotiation to accept either `mqtt` or `mqttv3.1` subprotocols. The handler uses `lists:search/2` to find the first matching protocol and echoes that exact value back in the `sec-websocket-protocol` response header, ensuring proper protocol negotiation with the client.
the-mikedavis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like VerneMQ has similar handling code for sec-websocket-protocol and matching mqttv3.1 or mqtt: https://github.com/vernemq/vernemq/blob/main/apps/vmq_server/src/vmq_websocket.erl. We should also follow this approach and parse this header as a list, checking membership with supported protocols.
|
@the-mikedavis yep that's exactly what this PR does, minus the macro 😸 |
|
Aha, Looks like it's guaranteed to be a list of binaries: https://github.com/ninenines/cowlib/blob/f30cc9e2fbb14705751cbe2c32895f59d91e4906/src/cow_http_hd.erl#L2851-L2855 |
Support `mqttv3.1` WebSocket subprotocol in addition to `mqtt` (backport #15008)
Addresses #15001
The Web MQTT handler only accepts the
mqttWebSocket subprotocol, rejecting clients that requestmqttv3.1. This prevents some MQTT clients from establishing WebSocket connections.This change updates the protocol negotiation to accept either
mqttormqttv3.1subprotocols. The handler useslists:search/2to find the first matching protocol and echoes that exact value back in thesec-websocket-protocolresponse header, ensuring proper protocol negotiation with the client.