pycom / pycom-libraries

MicroPython libraries and examples that work out of the box on Pycom's IoT modules
330 stars 379 forks source link

fix implementation of connect header to allow header sized above 128 bytes #131

Open superkartoffel opened 3 years ago

superkartoffel commented 3 years ago

What does this implement/fix? Explain your changes.

This change fixes a bug in the mqtt.py CONNECT message implementation, where the connection would be reset by the broker right after your device has send the CONNECT message. The error is, that mqtt.py does implement the "Remaining Length" field correctly for values above 128.

Does this close any currently open issues?

130

Any other comments?

The publish packet seems to implement this field correctly. Anyway, I only found that out after fixing the bug myself, so feel free to reject or modify the PR.

Where has this been tested?

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

stevegoobermanhill commented 2 years ago

This is not just an issue with the connect() message - it is also implicit in subscribe(). It is particularly a problem when working with modern cloud-based MQTT brokers (eg MS Azure IoT Hub) where the connection credentials and topic names can be long, exceeding the implicit assumption of a 127 byte maximum