Skip to content

MQTT QOS=1,2 rules state that pid must be > 0. #79

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

Merged
merged 1 commit into from
Apr 5, 2021

Conversation

dlizotte-uwo
Copy link
Contributor

Publishing with QOS 1 seemed to be broken because PID was incremented immediately after putting into packet, meaning that the PUBACK packet would not match the new (incremented) PID.

There is a danger if publishing more than 0xFFFF packets that .to_bytes will fail because it can't pack into 2 bytes after that. PID must wrap around to 1, not 0, according to spec, which demands that PID be nonzero for QOS 1 and 2.

@askpatrickw askpatrickw requested a review from brentru April 3, 2021 17:11
@brentru
Copy link
Member

brentru commented Apr 5, 2021

@dlizotte-uwo I tested and verified on wireshark that the packet identifier for pub/sub is => 1 when qos >1, also checked fields for anything malformed. Looks good:
Capturing_from_USB_10_100_1000_LAN__en7

There is a danger if publishing more than 0xFFFF packets that .to_bytes will fail because it can't pack into 2 bytes after that. PID must wrap around to 1, not 0, according to spec, which demands that PID be nonzero for QOS 1 and 2.

I'm ok with wrapping to 1, thank you for handling this edge case.

@brentru brentru merged commit c19c836 into adafruit:master Apr 5, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 6, 2021
rtwfroody pushed a commit to rtwfroody/Adafruit_CircuitPython_MiniMQTT that referenced this pull request Sep 18, 2022
MQTT QOS=1,2 rules state that pid must be > 0.
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

Successfully merging this pull request may close these issues.

2 participants