adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

packet_id_counter incrementing even if packet is dropped

eguarda opened this issue · 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.