tuanpmt / esp_mqtt

MQTT client library for ESP8266
http://tuanpm.net/post/esp_mqtt/
MIT License
1.15k stars 401 forks source link

lost messages with QoS == 2 #129

Closed st0ff3r closed 7 years ago

st0ff3r commented 7 years ago

From debugging the transmission from espmqtt to mosquitto broker it seems that if the the first message with type MQTT_MSG_TYPE_PUBLISH got lost and never received by the broker there is no retransmission and the message is lost. Is that right understood?

Second question: in mqtt_msg_init() when called from mqtt_tcpclient_connect_cb() shouldn't connection->message_id be saved if not clean session and QoS > 0, so message id is not going to overlap with messages from the session on the broker?

tuanpmt commented 7 years ago

i'm porting this library to Arduino: https://github.com/esp8266/Arduino/pull/2715 with outbox and have tested with qos=2. About qos, you can check here for your understand: https://code.google.com/archive/p/mqtt4erl/wikis/QualityOfServiceUseCases.wiki

st0ff3r commented 7 years ago

I think the queue code should be replaced with a linked list so messages can be stored until successfully delivery (PUBCOMP) and then removed from the queue. The problem occurs if the network silently drops the PUBLISH (QoS == 2), then the whole MQTT messages is never transmitted.

tuanpmt commented 7 years ago

yes @st0ff3r i've implemented it here: https://github.com/tuanpmt/Arduino/blob/master/libraries/ESP8266MQTTClient/src/mqtt_outbox.c After testing and stability on the Arduino, I will merge it inot esp_mqtt

st0ff3r commented 7 years ago

Cool, I am really looking forward to have it in the esp_mqtt version - thanx a lot for the nice work :)