Esp-mqtt receiving messages with empty payload

Hi.

I’m using the esp-idf framework in platformio. In general it works fine for me, but I figured out that sending a mqtt message to the ESP32 without payload (len=0) is received by the client, but not handed over to the subscription user. I googled it on the esp-idf GitHub repository and found a communication on this with a suggested bug fix:
esp-mqtt: receiving messages with empty payload (IDFGH-651) · Issue #3088 · espressif/esp-idf · GitHub
It also mention that it was already integrated to the stack. Is it possible, that this wasn’t included so far in the libraries platformio is using?

Error case: topic: std/dev98/r/0/gen/cmd, payload:
D (1119588) MQTT_CLIENT: msg_type=3, msg_id=0
D (1119588) MQTT_CLIENT: msg_type=3, msg_id=0
D (1119588) MQTT_CLIENT: deliver_publish, message_length_read=25, message_length=25

Good case: topic: std/dev98/r/0/gen/cmd, payload:“iii”
D (1234688) MQTT_CLIENT: msg_type=3, msg_id=0
D (1234688) MQTT_CLIENT: msg_type=3, msg_id=0
D (1234688) MQTT_CLIENT: deliver_publish, message_length_read=28, message_length=28
D (1234688) MQTT_CLIENT: Get data len= 3, topic len=21
(user code starts here with EVENT notification)
D (1234698) mqttdrv: MQTT_EVENT_DATA
D (1234698) mqttdrv: topic=std/dev98/r/0/gen/cmd, length: 21
D (1234708) mqttdrv: data=iii, length: 3

The fixes were merged into the v4.0 branch (refer mqtt: referenced esp-mqtt master to close disconnection issues and fi… · espressif/esp-idf@6289a26 · GitHub) and are now part of the v4.0 release. Since PIO doesn’t support beta software we’ve been on the v3.3 release for some time. Version v4.0 was released 2 days ago so it hasn’t been integrated yet, but support is surely being worked on.

In the meantime, it might be possible that the code is still v3.3 compatible, so downloading it and using it to replace the framework-espidf/components/mqtt/esp-mqtt folder might be possible. This folder is located in the PIO packages directory ( C:\Users\<user>\.platformio\packages or /home/<user>/.platformio/packages). Does that work?

1 Like

Hi maxgerhardt,

Thanks for the fast response. It explains why this fix not available right now. As it is not that urgent, I will wait for now for the new version. If it gets more urgent, I will come back to the fix and give it a try.

Thanks again for your support!

Regards

Stephan