communication
protocol_error
ai_generated
true
MQTT CONNACK: packet identifier already in use
ID: communication/mqtt-packet-identifier-in-use
76%Fix Rate
81%Confidence
1Evidence
2023-04-18First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Mosquitto 2.0.15 | active | — | — | — |
| Paho MQTT 1.3.12 | active | — | — | — |
| EMQX 5.0 | active | — | — | — |
Root Cause
The MQTT client sent a PUBLISH or SUBSCRIBE packet with a packet identifier that is already in use for an outstanding acknowledgment, violating the MQTT protocol specification.
generic中文
MQTT 客户端发送的 PUBLISH 或 SUBSCRIBE 数据包使用了尚未确认的重复数据包标识符,违反了 MQTT 协议规范。
Official Documentation
https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901194Workarounds
-
76% success Implement a proper packet identifier manager that reuses IDs only after acknowledgment or timeout. Example in C using Paho: `MQTTAsync_setCallbacks(client, NULL, connlost, msgarrvd, onDeliveryComplete)` and track IDs via a hash set.
Implement a proper packet identifier manager that reuses IDs only after acknowledgment or timeout. Example in C using Paho: `MQTTAsync_setCallbacks(client, NULL, connlost, msgarrvd, onDeliveryComplete)` and track IDs via a hash set.
-
70% success Increase `max_inflight_messages` in broker config (e.g., Mosquitto: `max_inflight_messages 20`) to reduce identifier reuse pressure.
Increase `max_inflight_messages` in broker config (e.g., Mosquitto: `max_inflight_messages 20`) to reduce identifier reuse pressure.
中文步骤
Implement a proper packet identifier manager that reuses IDs only after acknowledgment or timeout. Example in C using Paho: `MQTTAsync_setCallbacks(client, NULL, connlost, msgarrvd, onDeliveryComplete)` and track IDs via a hash set.
Increase `max_inflight_messages` in broker config (e.g., Mosquitto: `max_inflight_messages 20`) to reduce identifier reuse pressure.
Dead Ends
Common approaches that don't work:
-
50% fail
Disabling QoS entirely (QoS 0) avoids identifiers but loses delivery guarantees.
-
80% fail
Manually incrementing packet IDs without tracking acknowledgments still causes collisions.
-
70% fail
Restarting the broker clears state but doesn't fix the client's identifier management logic.