Adafruit_MQTT_Library icon indicating copy to clipboard operation
Adafruit_MQTT_Library copied to clipboard

packet_id_counter incrementing even if packet is dropped

Open eguarda opened this issue 3 years ago • 0 comments

Hello! I found that during the publish routine (bool Adafruit_MQTT::publish(...)), using QoS = 1, the packet_id_counter variable gets incremented even if the length check fails. Therefore, if a package is dropped, the counter adds one, but the broker counter doesn't, so it perpetually fails the packnum != packet_id_counter check because of an offset in these two counters.

This would make it so the microcontroller would incorrectly assume that it's failing every publish, making it so you couldn't send multiple messages during one MQTT connection using QoS > 0 if even a single publish message is dropped.

I'm using an ESP32 connected to a SIM800 module, and sending messages to a public HiveMQ topic.

eguarda avatar Feb 02 '22 13:02 eguarda