-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's the max size for publish in esp8266 #109
Comments
The max size is:
After spending a long time pulling my hair to understand why I was Turns out the memory corruption was caused by my publish |
Fixes adafruit#109 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 (see buffer[MAXBUFFERSIZE]). To protect myself from ever making this mistake again, I am proposing a simple logic in publishPacket where instead of silently corrupting memory, the code uses as much payload as it can fit in the available space. By seeing the truncated payload, user can decide whether he/she should 1)break it up into different topics, 2) put the payload on a diet, or 3) increase MAXBUFFERSIZE.
Fixes adafruit#109 Fixes adafruit#122 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 (see buffer[MAXBUFFERSIZE]). To protect myself from ever making this mistake again, I am proposing a simple logic in publishPacket where instead of silently corrupting memory, the code uses as much payload as it can fit in the available space. By seeing the truncated payload, user can decide whether he/she should 1)break it up into different topics, 2) put the payload on a diet, or 3) increase MAXBUFFERSIZE.
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
Avoid memory corruption from happening when data payload provided in Adafruit_MQTT::publishPacket is greater than MAXBUFFERSIZE. In order to do that, a helper function is being added to calculate how much space is available for the payload after subtracting what is used as the header. Pull request adafruit#166 Fixes adafruit#109 Fixes adafruit#122 Signed-off-by: Flavio Fernandes <flavio@flaviof.com>
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)
+ ", "YouRenJudgeInterval":" + String(g_YouRenJudgeInterval) + ", "qiTiAlertInterval":" + String(g_qiTiAlertInterval) + ", "iGapAlertPubUpdate":" + String(g_iGapAlertPubUpdate)
+ ", "strPhone":" + g_strPhone + ", "iHideUrl":" + String(g_iHideUrl) + ", "strQQ":" + g_strQQ + ", "iVer":" + String(g_iVer)
The text was updated successfully, but these errors were encountered: