{
  "id": "communication/mqtt-publish-identifier-in-use",
  "signature": "MQTT CONNACK returned with identifier rejected (0x02) or server unavailable (0x03)",
  "signature_zh": "MQTT CONNACK 返回标识符被拒绝 (0x02) 或服务器不可用 (0x03)",
  "regex": "CONNACK.*returned.*identifier rejected|server unavailable|0x02|0x03",
  "domain": "communication",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "MQTT broker rejected the client connection because the client identifier is already in use with a clean session not set, or the broker's connection limit has been reached.",
  "root_cause_type": "generic",
  "root_cause_zh": "MQTT 代理拒绝客户端连接，因为客户端标识符已被使用且未设置清除会话，或代理的连接数已达上限。",
  "versions": [
    {
      "version": "Mosquitto 2.0.15",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "EMQX 5.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "AWS IoT Core",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Paho MQTT 1.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reconnect with the same client ID repeatedly without changing anything",
      "why_fails": "The broker continues to reject the same client ID if the session is still active or limit persists.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Disable all security settings on the broker (e.g., remove authentication)",
      "why_fails": "May violate security policies and does not address the client ID conflict or connection limit.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a random client ID on every reconnect without setting clean session",
      "why_fails": "Random IDs may still conflict if not unique; without clean session, the broker retains state for each ID, potentially exhausting resources.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set the clean session flag to true in the CONNECT packet, e.g., in Paho Python: `client.connect(broker, port, keepalive=60, clean_session=True)`.",
      "success_rate": 0.9,
      "how": "Set the clean session flag to true in the CONNECT packet, e.g., in Paho Python: `client.connect(broker, port, keepalive=60, clean_session=True)`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Generate a unique client ID for each connection using a UUID or device-specific identifier, e.g., `client_id = f\"device-{uuid.uuid4()}\"`.",
      "success_rate": 0.95,
      "how": "Generate a unique client ID for each connection using a UUID or device-specific identifier, e.g., `client_id = f\"device-{uuid.uuid4()}\"`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase the maximum number of concurrent connections on the broker, e.g., in Mosquitto: add `max_connections 1000` to `mosquitto.conf`.",
      "success_rate": 0.85,
      "how": "Increase the maximum number of concurrent connections on the broker, e.g., in Mosquitto: add `max_connections 1000` to `mosquitto.conf`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在 CONNECT 数据包中将清除会话标志设置为 true，例如在 Paho Python 中：`client.connect(broker, port, keepalive=60, clean_session=True)`。",
    "为每个连接生成唯一的客户端 ID，使用 UUID 或设备特定标识符，例如 `client_id = f\"device-{uuid.uuid4()}\"`。",
    "增加代理上的最大并发连接数，例如在 Mosquitto 中：在 `mosquitto.conf` 中添加 `max_connections 1000`。"
  ],
  "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#_Toc3901081",
  "official_doc_section": null,
  "error_code": "0x02",
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.83,
  "resolvable": "true",
  "first_seen": "2024-02-28",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}