Skip to content
Back to skills

Mqtt

ASecurity

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

  • 17 stars
  • 0 votes
  • 0 copies
  • 10 views
  • Added September 6, 2026
designdebuggingsecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 6, 2026

npx -y skills add clawic/skills --skill mqtt --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mqtt?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mqtt
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/clawic-mqtt/badge)](https://www.skillsdirectory.com/skills/clawic-mqtt)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: MQTT
slug: mqtt
version: 1.0.0
description: Implement MQTT messaging avoiding security, QoS, and connection management pitfalls.
homepage: https://clawic.com/skills/mqtt
metadata:
  clawdbot:
    emoji: 📡
    os:
    - linux
    - darwin
    - win32
    displayName: 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

Files in this skill

  • SKILL.md2.6 KB
  • _meta.json160 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in design →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.