-
Notifications
You must be signed in to change notification settings - Fork 258
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
esp_mqtt_client_publish with data longer than buffer causes disconnect and issues with Mosquitto (IDFGH-6461) #214
Comments
@DCSBL Please use this patch and test |
Thanks. Tested with same example and espressif/esp-idf@279c8ae. Confirmed that this patch fixes my issue. |
I am not really sure, but it seems that this test does not tests payloads larger than the buffer size. The largest payload is tested with Is it possible to test for this to prevent something like this issue? |
@DCSBL Thanks for pointing out it. I think it is a good idea, we will implement it. |
* Fix sending mqtt message longer than Tx buffer size * Fix enqueue API to send data with correct dup flag * Update submodule: git log --oneline b86d42c130ac64a916ce6cf299d99f9756692394..985078affa8a2d2b56b87c8e6455252850f895c6 Detailed description of the changes: * Isolate IDF env for v4.4 and v5.0(master) - See merge request espressif/esp-mqtt!111 - ci: Isolate IDF env for v4.4 and v5.0(master) (espressif/esp-mqtt@4c5a65c) * Client: Remove usage of legacy FreeRTOS types - See merge request espressif/esp-mqtt!120 - ci: Fix build issues with IDF-4.4 against master (espressif/esp-mqtt@c28a56d) - See commit espressif/esp-mqtt@6ef98d6 * mqtt_client: Fix mqtt send long data error - See merge request espressif/esp-mqtt!117 - Closes espressif/esp-mqtt#214 - See commit espressif/esp-mqtt@372b323 * Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 - See merge request espressif/esp-mqtt!116 - See commit espressif/esp-mqtt@df8dc92
* Fix sending mqtt message longer than Tx buffer size * Fix enqueue API to send data with correct dup flag * Update submodule: git log --oneline b86d42c130ac64a916ce6cf299d99f9756692394..985078affa8a2d2b56b87c8e6455252850f895c6 Detailed description of the changes: * Isolate IDF env for v4.4 and v5.0(master) - See merge request espressif/esp-mqtt!111 - ci: Isolate IDF env for v4.4 and v5.0(master) (espressif/esp-mqtt@4c5a65c) * Client: Remove usage of legacy FreeRTOS types - See merge request espressif/esp-mqtt!120 - ci: Fix build issues with IDF-4.4 against master (espressif/esp-mqtt@c28a56d) - See commit espressif/esp-mqtt@6ef98d6 * mqtt_client: Fix mqtt send long data error - See merge request espressif/esp-mqtt!117 - Closes espressif/esp-mqtt#214 - See commit espressif/esp-mqtt@372b323 * Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 - See merge request espressif/esp-mqtt!116 - See commit espressif/esp-mqtt@df8dc92
* Fix sending mqtt message longer than Tx buffer size * Fix enqueue API to send data with correct dup flag * Update submodule: git log --oneline b86d42c130ac64a916ce6cf299d99f9756692394..985078affa8a2d2b56b87c8e6455252850f895c6 Detailed description of the changes: * Isolate IDF env for v4.4 and v5.0(master) - See merge request espressif/esp-mqtt!111 - ci: Isolate IDF env for v4.4 and v5.0(master) (espressif/esp-mqtt@4c5a65c) * Client: Remove usage of legacy FreeRTOS types - See merge request espressif/esp-mqtt!120 - ci: Fix build issues with IDF-4.4 against master (espressif/esp-mqtt@c28a56d) - See commit espressif/esp-mqtt@6ef98d6 * mqtt_client: Fix mqtt send long data error - See merge request espressif/esp-mqtt!117 - Closes espressif/esp-mqtt#214 - See commit espressif/esp-mqtt@372b323 * Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 - See merge request espressif/esp-mqtt!116 - See commit espressif/esp-mqtt@df8dc92
* Fix sending mqtt message longer than Tx buffer size * Fix enqueue API to send data with correct dup flag * Update submodule: git log --oneline b86d42c130ac64a916ce6cf299d99f9756692394..985078affa8a2d2b56b87c8e6455252850f895c6 Detailed description of the changes: * Isolate IDF env for v4.4 and v5.0(master) - See merge request espressif/esp-mqtt!111 - ci: Isolate IDF env for v4.4 and v5.0(master) (espressif/esp-mqtt@4c5a65c) * Client: Remove usage of legacy FreeRTOS types - See merge request espressif/esp-mqtt!120 - ci: Fix build issues with IDF-4.4 against master (espressif/esp-mqtt@c28a56d) - See commit espressif/esp-mqtt@6ef98d6 * mqtt_client: Fix mqtt send long data error - See merge request espressif/esp-mqtt!117 - Closes espressif/esp-mqtt#214 - See commit espressif/esp-mqtt@372b323 * Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 - See merge request espressif/esp-mqtt!116 - See commit espressif/esp-mqtt@df8dc92
* Fix sending mqtt message longer than Tx buffer size * Fix enqueue API to send data with correct dup flag * Update submodule: git log --oneline b86d42c130ac64a916ce6cf299d99f9756692394..985078affa8a2d2b56b87c8e6455252850f895c6 Detailed description of the changes: * Isolate IDF env for v4.4 and v5.0(master) - See merge request espressif/esp-mqtt!111 - ci: Isolate IDF env for v4.4 and v5.0(master) (espressif/esp-mqtt@4c5a65c) * Client: Remove usage of legacy FreeRTOS types - See merge request espressif/esp-mqtt!120 - ci: Fix build issues with IDF-4.4 against master (espressif/esp-mqtt@c28a56d) - See commit espressif/esp-mqtt@6ef98d6 * mqtt_client: Fix mqtt send long data error - See merge request espressif/esp-mqtt!117 - Closes espressif/esp-mqtt#214 - See commit espressif/esp-mqtt@372b323 * Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 - See merge request espressif/esp-mqtt!116 - See commit espressif/esp-mqtt@df8dc92
* Fix sending mqtt message longer than Tx buffer size * Fix enqueue API to send data with correct dup flag * Update submodule: git log --oneline b86d42c..985078a Detailed description of the changes: * Isolate IDF env for v4.4 and v5.0(master) - See merge request espressif/esp-mqtt!111 - ci: Isolate IDF env for v4.4 and v5.0(master) (4c5a65c) * Client: Remove usage of legacy FreeRTOS types - See merge request espressif/esp-mqtt!120 - ci: Fix build issues with IDF-4.4 against master (c28a56d) - See commit 6ef98d6 * mqtt_client: Fix mqtt send long data error - See merge request espressif/esp-mqtt!117 - Closes #214 - See commit 372b323 * Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 - See merge request espressif/esp-mqtt!116 - See commit df8dc92
* Fix sending mqtt message longer than Tx buffer size * Fix enqueue API to send data with correct dup flag * Update submodule: git log --oneline b86d42c..985078a Detailed description of the changes: * Isolate IDF env for v4.4 and v5.0(master) - See merge request espressif/esp-mqtt!111 - ci: Isolate IDF env for v4.4 and v5.0(master) (espressif/esp-mqtt@4c5a65c) * Client: Remove usage of legacy FreeRTOS types - See merge request espressif/esp-mqtt!120 - ci: Fix build issues with IDF-4.4 against master (espressif/esp-mqtt@c28a56d) - See commit espressif@6ef98d6 * mqtt_client: Fix mqtt send long data error - See merge request espressif/esp-mqtt!117 - Closes espressif#214 - See commit espressif@372b323 * Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 - See merge request espressif/esp-mqtt!116 - See commit espressif@df8dc92
* Fix sending mqtt message longer than Tx buffer size * Fix enqueue API to send data with correct dup flag * Update submodule: git log --oneline b86d42c..985078a Detailed description of the changes: * Isolate IDF env for v4.4 and v5.0(master) - See merge request espressif/esp-mqtt!111 - ci: Isolate IDF env for v4.4 and v5.0(master) (espressif/esp-mqtt@4c5a65c) * Client: Remove usage of legacy FreeRTOS types - See merge request espressif/esp-mqtt!120 - ci: Fix build issues with IDF-4.4 against master (espressif/esp-mqtt@c28a56d) - See commit espressif@6ef98d6 * mqtt_client: Fix mqtt send long data error - See merge request espressif/esp-mqtt!117 - Closes espressif#214 - See commit espressif@372b323 * Client: Fix use esp_mqtt_client_enqueue API to send data, data dup flag will be set 1 - See merge request espressif/esp-mqtt!116 - See commit espressif@df8dc92
Summary
When using
esp_mqtt_client_publish
with a message longer than the buffer size (MQTT_BUFFER_SIZE_BYTE
), the client disconnects and Mosquitto receives garbage data.Environment
Tested with ESP-IDF:
v4.1.2
,v4.3
and[master]
@ (espressif/esp-idf@279c8ae), (Issue not present onv4.1
)Tested with selected esp-mqtt submobule and with 383e7e5.
ESP32-WROOM-32D
Mosquitto
2.0.14
with this config:How to reproduce
Used this example https://github.com/espressif/esp-idf/tree/master/examples/protocols/mqtt/ws @ espressif/esp-idf@279c8ae
Configured example project with Wifi SSID and pass and MQTT server address.
Added this at line 63 (after sending
topic/qos0
/"data"
(string with +1200 characters):case MQTT_EVENT_SUBSCRIBED: ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id); msg_id = esp_mqtt_client_publish(client, "/topic/qos0", "data", 0, 0, 0); ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id); + msg_id = esp_mqtt_client_publish(client, "/topic/long", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse nibh nibh, tempus ut vulputate in, auctor eu quam. Suspendisse vel auctor nisi. Nam tellus erat, porta auctor vulputate vel, venenatis id arcu. Phasellus a viverra risus. Maecenas imperdiet nibh augue, ut malesuada sapien scelerisque eget. Donec iaculis dui ut ultrices interdum. Maecenas convallis mattis lobortis. Quisque ac congue ipsum, eu mollis est. Pellentesque nec ante leo. Nam a ipsum tristique, sagittis nunc non, mollis sapien. Cras quam urna, consectetur ut tellus vulputate, venenatis suscipit mi. Proin pretium arcu convallis, dictum dolor vitae, ultricies nulla. Integer id eleifend mauris. Integer iaculis, augue ut mattis tempor, est felis sodales justo, ac interdum lacus orci non eros. Nulla accumsan ut arcu sed ornare. Ut aliquet erat vel eleifend consequat. Ut sit amet tincidunt eros. Vivamus nec libero ut velit pretium molestie. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam rhoncus nisi ut interdum blandit. Fusce tincidunt dictum tellus, sit amet suscipit ex fermentum tempus. Integer feugiat iaculis volutpat. Pellentesque habitant morbi tristique posuere.", 0, 0, 0); + ESP_LOGI(TAG, "sent long publish successful, msg_id=%d", msg_id); break;
Uploaded to ESP, got the following result:
Click to see full verbose log
I've also subscribed to the topics to see the what is send (
mosquitto_sub -v -h 192.168.5.119 -t '#'
). Here you see that there is some weird characters being send (I think a missing null terminator).The text was updated successfully, but these errors were encountered: