Skip to content
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

Does not support Disconnect message #291

Open
dscso opened this issue May 21, 2024 · 1 comment
Open

Does not support Disconnect message #291

dscso opened this issue May 21, 2024 · 1 comment

Comments

@dscso
Copy link
Contributor

dscso commented May 21, 2024

If using this command to publish a message the parser fails parsing the disconnect packet:

 mosquitto_pub -h 192.168.178.101 -t /test -m "mylittlemessage" -V mqttv5
Screenshot 2024-05-21 at 12 14 42
#[test]
fn test_disconnect_packet() {
    let buf = [0xe0, 0x00];
    let parsed = MqttPacket::parse_complete(&buf).unwrap();
}

this is not working unfortunately results in an error:

called `Result::unwrap()` on an `Err` value: Backtrack(ContextError { context: PhantomData<winnow::error::StrContext> })
thread 'v5::packets::disconnect::test::test_disconnect_packet' panicked at mqtt-format/src/v5/packets/disconnect.rs:144:55:
called `Result::unwrap()` on an `Err` value: Backtrack(ContextError { context: PhantomData<winnow::error::StrContext> })
stack backtrace:

The disconnect packet seems to be a special case.
In the standard there is written:

The Client or Server sending the DISCONNECT packet MUST use one of the DISCONNECT Reason Code values [MQTT-3.14.2-1]. The Reason Code and Property Length can be omitted if the Reason Code is 0x00 (Normal disconnecton) and there are no Properties. In this case the DISCONNECT has a Remaining Length of 0.

PR incoming...

@dscso
Copy link
Contributor Author

dscso commented May 21, 2024

aaah maybe we have to add this on the serializing side as well to save traffic (2 bytes per disconnect idk if it is worth it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant