返回顶部
M

MQTT

Implement MQTT messaging avoiding security, QoS, and connection management pitfalls.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
1,281
下载量
2
收藏
概述
安装方式
版本历史

MQTT

## Security Traps - Default Mosquitto allows anonymous connections — bots scan constantly, always configure auth - TLS mandatory for external access — credentials travel plaintext otherwise - Duplicate client IDs cause connection fights — both clients repeatedly disconnect each other - ACLs should restrict topic access — one compromised device shouldn't read all topics ## QoS Misunderstandings - Effective QoS is minimum of publisher and subscriber — broker downgrades if subscriber requests lower - QoS 1 may duplicate messages — handlers must be idempotent - QoS 2 has significant overhead — only use for commands where duplicates cause problems - QoS applies per-message — can mix within same topic ## Topic Design Pitfalls - Starting with `/` creates empty first level — `home/temp` not `/home/temp` - Wildcards only work in subscriptions — can't publish to `home/+/temperature` - `#` matches everything including nested — `home/#` gets `home/a/b/c/d` - Some brokers limit topic depth — check before designing deep hierarchies ## Connection Management - Clean session false preserves subscriptions — messages queue while disconnected, can surprise - Keep-alive too long = delayed dead client detection — 60s is reasonable default - Reconnection logic is client responsibility — most libraries don't auto-reconnect by default - Will message only fires on unexpected disconnect — clean disconnect doesn't trigger it ## Retained Message Traps - Retained messages persist until explicitly cleared — old data confuses new subscribers - Clear retained with empty message + retain flag — not obvious from docs - Birth/will pattern: publish "online" retained on connect, will publishes "offline" ## Mosquitto Specifics - `persistence true` survives restarts — without it, retained messages and subscriptions lost - `max_queued_messages` prevents memory exhaustion — one slow subscriber shouldn't crash broker - `listener 1883 0.0.0.0` binds all interfaces — use `127.0.0.1` for local-only ## Debugging - Subscribe to `#` sees all traffic — never in production, leaks everything - `$SYS/#` exposes broker metrics — client count, bytes, subscriptions - Retained messages persist after fixing issues — explicitly clear them - `mosquitto_sub -v` shows topic with message — essential for debugging

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 mqtt-1776420088 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 mqtt-1776420088 技能

通过命令行安装

skillhub install mqtt-1776420088

下载 Zip 包

⬇ 下载 MQTT v1.0.0

文件大小: 1.82 KB | 发布时间: 2026-4-17 19:56

v1.0.0 最新 2026-4-17 19:56
Initial release

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部