Adafruit_MQTT_Library icon indicating copy to clipboard operation
Adafruit_MQTT_Library copied to clipboard

Packet size limited to 127 bytes in connect and subscribe

Open anaptfox opened this issue 7 years ago • 3 comments

  • Arduino board: Feather Huzzah

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.0

  • List the steps to reproduce the problem below (if possible attach a sketch or copy the sketch code in too):

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.

anaptfox avatar May 09 '17 23:05 anaptfox

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.

GeirFrimann avatar May 12 '17 18:05 GeirFrimann

theres no ETA for a fix!

ladyada avatar May 12 '17 18:05 ladyada

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.

kmatch98 avatar Nov 12 '17 01:11 kmatch98