{
  "id": "communication/mqtt-packet-identifier-in-use",
  "signature": "MQTT CONNACK: packet identifier already in use",
  "signature_zh": "MQTT CONNACK: 数据包标识符已被占用",
  "regex": "MQTT CONNACK: packet identifier already in use",
  "domain": "communication",
  "category": "protocol_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "MQTT 客户端发送的 PUBLISH 或 SUBSCRIBE 数据包使用了尚未确认的重复数据包标识符，违反了 MQTT 协议规范。",
  "versions": [
    {
      "version": "Mosquitto 2.0.15",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Paho MQTT 1.3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "EMQX 5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Disabling QoS entirely (QoS 0) avoids identifiers but loses delivery guarantees.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Manually incrementing packet IDs without tracking acknowledgments still causes collisions.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Restarting the broker clears state but doesn't fix the client's identifier management logic.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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.",
      "success_rate": 0.76,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase `max_inflight_messages` in broker config (e.g., Mosquitto: `max_inflight_messages 20`) to reduce identifier reuse pressure.",
      "success_rate": 0.7,
      "how": "Increase `max_inflight_messages` in broker config (e.g., Mosquitto: `max_inflight_messages 20`) to reduce identifier reuse pressure.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901194",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.81,
  "fix_success_rate": 0.76,
  "resolvable": "true",
  "first_seen": "2023-04-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [
    "MQTT",
    "packet-id",
    "protocol"
  ],
  "locale": "en",
  "aliases": []
}