adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
573 stars 291 forks source link

Packet size limited to 127 bytes in connect and subscribe #79

Open anaptfox opened 7 years ago

anaptfox commented 7 years ago

I'm experiencing this same issue:

https://github.com/adafruit/Adafruit_MQTT_Library/issues/17#issuecomment-231225233

This issue is in byte 2 of the packet:

https://github.com/adafruit/Adafruit_MQTT_Library/blob/master/Adafruit_MQTT.cpp#L628

The variable length encoding scheme uses a single byte for messages up to 127 bytes long. Longer messages are handled as follows. Seven bits of each byte encode the Remaining Length data, and the eighth bit indicates any following bytes in the representation. Each byte encodes 128 values and a "continuation bit". For example, the number 64 decimal is encoded as a single byte, decimal value 64, hex 0x40. The number 321 decimal (= 65 + 2*128) is encoded as two bytes, least significant first. The first byte 65+128 = 193. Note that the top bit is set to indicate at least one following byte. The second byte is 2.

This issue was fixed in Publish ( in issue #17), but not in Connect or Subscribe. In both you are limited to 127 bytes.

GeirFrimann commented 7 years ago

Is anyone looking into addressing this issue? I's critical for me to get the Adafruit Feather 32u4 FONA to connect to Losant's MQTT broker.

ladyada commented 7 years ago

theres no ETA for a fix!

kmatch98 commented 6 years ago

I resolved an error in readSubscription that was not adjusting the buffer index references based on the number of header “length” bytes.

I just submitted a fork request. This is my first attempt on github so bear with me if I did something wrong.