mqttjs / mqtt-packet

Parse and generate MQTT packets like a breeze in JS
Other
206 stars 93 forks source link

fix: PUBACK packet not compatible with RabbitMQ #142

Closed alaendle closed 1 year ago

alaendle commented 1 year ago

MQTT5 spec is not so clear about the possible remaining length of PUBACK pakets.

We have:

To state my belief - if it were intended to be able to omit both bytes individually, it wouldn't makle sense limit this to reason code 0x00 - why should [64, 3, 0, 42, 0] be allowed, while [64, 3, 0, 42, 135] is not?

Fixes #92

robertsLando commented 1 year ago

@alaendle remember to add a test suite that covers the issue

alaendle commented 1 year ago

Please note that this is a breaking change on the wire - however it shouldn't be with regards to the specification. It could be further optimized by striving for length === 2 (but this would also need an additional complexity by checking the reason code). So I basically adapted the existing test code - because I fear there is no backwards compatible way to implement this. Tested against the "old" version of RabbitMQ that treated length === 3 as a protocol error.

alaendle commented 1 year ago

Please note I have added a description of the PR just now - https://github.com/mqttjs/mqtt-packet/pull/142#issue-1788020845 - to make sure we discuss the same things 😄

robertsLando commented 1 year ago

@mcollina Thoughts on this? It looks good to me, if you agree could you merge and release a patch?