adafruit / Adafruit_MQTT_Library

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

What's the max size for publish in esp8266 #109

Closed myie9 closed 3 years ago

myie9 commented 6 years ago

When publish long message as below. It would crash after receive some subscribe. But it' ok if publish short message. What's the max size for publish in esp8266?

String strConfig = "{\"iQiTiYuZhi\":" + String(g_iQiTiYuZhi) + ", \"iKeepAlertTime\":" + String(g_iKeepAlertTime) + ", \"iAlertWhenYouRen\":" + String(g_iAlertWhenYouRen)

flavio-fernandes commented 4 years ago

The max size is:

// Largest full packet we're able to send.
// Need to be able to store at least ~90 chars for a connect packet with full
// 23 char client ID.
#define MAXBUFFERSIZE (150)

After spending a long time pulling my hair to understand why I was hitting a panic when attempting to read from my registered subscriptions, I found out that the subscriptions member of the Adafruit_MQTT instance was corrupted. :(

Turns out the memory corruption was caused by my publish call, where the payload I was providing was bigger than the allocated space in the buffer for construction of the packet.

flavio-fernandes commented 4 years ago

@myie9 : Please take a look at https://github.com/adafruit/Adafruit_MQTT_Library/pull/166 and see if that addresses your issue.