espressif / esp-mqtt

ESP32 mqtt component
Apache License 2.0
611 stars 257 forks source link

MQTT QOS2 not resend PUBREC ACKNOWLEDGED message (IDFGH-10609) #262

Closed JunFlyFarm closed 1 year ago

JunFlyFarm commented 1 year ago

I want to make sure MQTT qos 2 never missing any message in the pretty bad network environment, so I just randomly cut the network to see whether it can maintain the message well or not. But seem somehow it will missing the message when I cut the network at the time it received MQTT_MSG_TYPE_PUBREC message Here is the Serial debug message: 16:56:41.578 -> D (13880) MQTT_CLIENT: mqtt_enqueue id: 38290, type=3 successful 16:56:41.578 -> D (13880) OUTBOX: ENQUEUE msgid=38290, msg_type=3, len=36, size=36 16:56:41.578 -> published: 38290 16:56:41.624 -> D (13908) MQTT_CLIENT: mqtt_message_receive: first byte: 0x50 16:56:41.624 -> D (13909) MQTT_CLIENT: mqtt_message_receive: read "remaining length" byte: 0x2 16:56:41.624 -> D (13910) MQTT_CLIENT: mqtt_message_receive: total message length: 4 (already read: 2) 16:56:41.624 -> D (13919) MQTT_CLIENT: mqtt_message_receive: read_len=2 16:56:41.624 -> D (13923) MQTT_CLIENT: mqtt_message_receive: transport_read():4 4 16:56:41.624 -> D (13930) MQTT_CLIENT: msg_type=5, msg_id=38290 16:56:41.671 -> D (13934) MQTT_CLIENT: received MQTT_MSG_TYPE_PUBREC 16:56:41.671 -> D (13974) MQTT_CLIENT: mqtt_message_receive: first byte: 0x70 16:56:41.671 -> D (13975) MQTT_CLIENT: mqtt_message_receive: read "remaining length" byte: 0x2 16:56:41.671 -> D (13976) MQTT_CLIENT: mqtt_message_receive: total message length: 4 (already read: 2) 16:56:41.718 -> D (13986) MQTT_CLIENT: mqtt_message_receive: read_len=2 16:56:41.718 -> D (13990) MQTT_CLIENT: mqtt_message_receive: transport_read():4 4 16:56:41.718 -> D (13996) MQTT_CLIENT: msg_type=7, msg_id=38290 16:56:41.718 -> D (14000) MQTT_CLIENT: received MQTT_MSG_TYPE_PUBCOMP 16:56:41.718 -> D (14006) MQTT_CLIENT: pending_id=38290, pending_msg_count = 1 16:56:41.718 -> D (14012) OUTBOX: DELETED msgid=38290, msg_type=3, remain size=0 16:56:41.718 -> D (14018) MQTT_CLIENT: Receive MQTT_MSG_TYPE_PUBCOMP, finish QoS2 publish 16:56:41.718 -> received: 38290 16:56:41.764 -> D (14035) MQTT_CLIENT: mqtt_enqueue id: 4845, type=3 successful 16:56:41.764 -> D (14036) OUTBOX: ENQUEUE msgid=4845, msg_type=3, len=36, size=36 16:56:41.764 -> published: 4845 16:56:41.764 -> D (14069) MQTT_CLIENT: mqtt_message_receive: first byte: 0x50 16:56:41.764 -> D (14070) MQTT_CLIENT: mqtt_message_receive: read "remaining length" byte: 0x2 16:56:41.764 -> D (14072) MQTT_CLIENT: mqtt_message_receive: total message length: 4 (already read: 2) 16:56:41.811 -> D (14080) MQTT_CLIENT: mqtt_message_receive: read_len=2 16:56:41.811 -> D (14085) MQTT_CLIENT: mqtt_message_receive: transport_read():4 4 16:56:41.811 -> D (14091) MQTT_CLIENT: msg_type=5, msg_id=4845 16:56:41.811 -> D (14096) MQTT_CLIENT: received MQTT_MSG_TYPE_PUBREC

16:57:01.363 -> I (33630) esp_netif_handlers: sta ip: 192.168.74.26, mask: 255.255.255.0, gw: 192.168.74.173 16:57:02.064 -> D (34359) MQTT_CLIENT: Reconnecting... 16:57:02.064 -> D (34359) esp-tls: host:192.168.0.9: strlen 11 16:57:02.064 -> D (34361) esp-tls: [sock=54] Resolved IPv4 address: 192.168.0.9 16:57:02.064 -> D (34363) esp-tls: [sock=54] Connecting to server. HOST: 192.168.0.9, Port: 1883 16:57:02.158 -> D (34430) MQTT_CLIENT: Transport connected to mqtt://192.168.0.9:1883 16:57:02.158 -> D (34431) MQTT_CLIENT: Sending MQTT CONNECT message, type: 1, id: 0000 16:57:02.158 -> D (34454) MQTT_CLIENT: mqtt_message_receive: first byte: 0x20 16:57:02.158 -> D (34455) MQTT_CLIENT: mqtt_message_receive: read "remaining length" byte: 0x2 16:57:02.158 -> D (34456) MQTT_CLIENT: mqtt_message_receive: total message length: 4 (already read: 2) 16:57:02.158 -> D (34465) MQTT_CLIENT: mqtt_message_receive: read_len=2 16:57:02.205 -> D (34470) MQTT_CLIENT: mqtt_message_receive: transport_read():4 4 16:57:02.205 -> D (34476) MQTT_CLIENT: Connected 16:57:02.205 -> {lib/mqtt_app/mqtt_app.cpp: 235} MQTT Connected; 16:57:02.205 -> D (34490) nvs: nvs_open_from_partition lifter 1 16:57:02.205 -> D (34490) nvs: nvs_get_str_or_blob device_name 16:57:02.205 -> D (34493) nvs: nvs_get_str_or_blob device_name 16:57:02.205 -> D (34498) nvs: nvs_get_str_or_blob section 16:57:02.205 -> D (34501) nvs: nvs_get_str_or_blob section 16:57:02.205 -> D (34508) nvs: nvs_get_str_or_blob macAddress 16:57:02.205 -> D (34510) nvs: nvs_get_str_or_blob macAddress 16:57:02.251 -> D (34515) nvs: nvs_get_str_or_blob version 16:57:02.251 -> D (34518) nvs: nvs_get_str_or_blob version 16:57:02.251 -> D (34525) nvs: nvs_close 30 Anyone know how to fix it? Thx New Text Document.txt