WebSocket transport accepts text data frames as MQTT bytes
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- networking
Research direction
Start in src/io/tokio_ws.rs around the receive-side Message::Binary and Message::Text branches. Verify the reproduction with an MQTT-over-WebSocket connection and confirm that binary frames still reach the MQTT decoder while text frames close the network connection. Done means text data is rejected without changing handling for binary, Ping, Pong, or Close frames.
Written by the indexing model from the issue text.
Description
Description
The MQTT-over-WebSocket receive adapter accepts WebSocket text data frames and feeds their UTF-8 bytes into the MQTT decoder instead of closing the network connection.
The binary and text branches currently differ only in how their payload becomes Bytes:
Message::Binary(next_read) => self.next_read = next_read,
Message::Text(next_read) => self.next_read = next_read.into(),
The public client API does not expose WebSocket frame selection, and the write side correctly sends MQTT data as binary:
This is therefore a receive-side validation bug, not an outgoing framing or payload data-loss bug.
Reproduction
-
Establish an MQTT-over-WebSocket connection using the
mqttWebSocket subprotocol. -
Have the server send bytes for a valid MQTT packet in a WebSocket text data frame. For example, this valid MQTT 5 QoS 0 PUBLISH to topic
awith no payload is also valid UTF-8 byte data:30 04 00 01 61 00 -
Observe that the adapter exposes those bytes to the MQTT reader and the packet can be processed.
The connection should instead be closed as soon as the text data frame is received, regardless of whether its bytes happen to form a valid MQTT packet.
Expected behavior
Accept WebSocket binary data frames as the MQTT byte stream. On receipt of a WebSocket text data frame, terminate the network connection rather than forwarding its contents to the MQTT decoder.
WebSocket Ping, Pong, and Close are control frames, not alternative data-frame types, and are outside this rejection rule.
MQTT 5.0 [MQTT-6.0.0-1] states:
MQTT Control Packets MUST be sent in WebSocket binary data frames. If any other type of data frame is received the recipient MUST close the Network Connection.
Specification: https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html
Audited revision
e2df553b4ee0bc7f2d7b45175ef9bfe600a8424d
- Dominant language
- Rust
- Stars
- 3
- Forks
- 3
- Avg merge
- 7d 8h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/rust-mqtt-client
-
bug
microsoft/rust-mqtt-client#151 · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
microsoft/rust-mqtt-client#141 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 64/100
microsoft/rust-mqtt-client#137 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
microsoft/rust-mqtt-client#136 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 72/100
microsoft/rust-mqtt-client#134 ·
All issues in microsoft/rust-mqtt-client
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100