{
  "id": "communication/mqtt-publish-failed-no-subscribers",
  "signature": "MQTT publish failed: no subscribers matched topic filter",
  "signature_zh": "MQTT 发布失败：无订阅者匹配主题过滤器",
  "regex": "no subscribers matched topic filter|no subscribers",
  "domain": "communication",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The MQTT broker discards the published message because no active subscribers are subscribed to the topic or any wildcard matching it.",
  "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": "Paho MQTT 1.6.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "EMQX 5.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Publish with QoS 2 to guarantee delivery even without subscribers",
      "why_fails": "QoS levels do not create subscribers; the broker still drops the message if no one is subscribed.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Enable broker's retained messages feature to store the last message",
      "why_fails": "Retained messages only store the last message per topic; they don't affect delivery of new messages to non-existent subscribers.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Set the 'clean session' flag to false on the publisher",
      "why_fails": "The clean session flag applies to client session state, not subscriber existence; it doesn't create subscribers.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure at least one subscriber is connected before publishing: In the publisher code, implement a callback to wait for a subscriber presence notification or use a separate health-check topic. For example, in Eclipse Paho Python client, subscribe to '$SYS/broker/clients/connected' to monitor.",
      "success_rate": 0.8,
      "how": "Ensure at least one subscriber is connected before publishing: In the publisher code, implement a callback to wait for a subscriber presence notification or use a separate health-check topic. For example, in Eclipse Paho Python client, subscribe to '$SYS/broker/clients/connected' to monitor.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use MQTT 5.0 subscription identifiers to track active subscribers: Set `SubscriptionIdentifier` in the publish packet and check broker response for 'no matching subscribers' reason code.",
      "success_rate": 0.75,
      "how": "Use MQTT 5.0 subscription identifiers to track active subscribers: Set `SubscriptionIdentifier` in the publish packet and check broker response for 'no matching subscribers' reason code.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Configure the broker to store undelivered messages with a queue for offline subscribers: In Mosquitto, set `persistence true` and use `max_queued_messages 1000` with a clean session false for the subscriber.",
      "success_rate": 0.85,
      "how": "Configure the broker to store undelivered messages with a queue for offline subscribers: In Mosquitto, set `persistence true` and use `max_queued_messages 1000` with a clean session false for the subscriber.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure at least one subscriber is connected before publishing: In the publisher code, implement a callback to wait for a subscriber presence notification or use a separate health-check topic. For example, in Eclipse Paho Python client, subscribe to '$SYS/broker/clients/connected' to monitor.",
    "Use MQTT 5.0 subscription identifiers to track active subscribers: Set `SubscriptionIdentifier` in the publish packet and check broker response for 'no matching subscribers' reason code.",
    "Configure the broker to store undelivered messages with a queue for offline subscribers: In Mosquitto, set `persistence true` and use `max_queued_messages 1000` with a clean session false for the subscriber."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://mqtt.org/mqtt-specification/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.75,
  "resolvable": "true",
  "first_seen": "2024-03-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}