Learn MQTT
Short, practical guides to the MQTT protocol — each one paired with something you can try in the online MQTT client.
Guides
How to Test an MQTT Broker (Online, CLI and Code)
Learn how to test an MQTT broker: check connectivity, publish and subscribe, verify QoS and retained messages, and debug failures — online, with the CLI or in code.
GuidesPublic MQTT Brokers vs Private Brokers: When to Switch
Public MQTT brokers are great for testing but risky for real data. Learn their limits, when they are fine, and what to look for in a private MQTT broker.
GuidesBest MQTT Brokers Compared: Mosquitto vs EMQX vs HiveMQ vs Managed
An honest MQTT broker comparison: Mosquitto, EMQX, HiveMQ, VerneMQ, NanoMQ and managed cloud brokers — language, clustering, MQTT 5, licenses and how to choose.
Guidesmosquitto_pub and mosquitto_sub: Command Examples & Cheat Sheet
Copy-paste mosquitto_pub and mosquitto_sub examples: flags table, QoS, retained messages, auth, TLS, MQTT 5, files, line mode and filtering output with -F.
GuidesSecure Mosquitto: Passwords, ACLs and TLS
Secure a Mosquitto broker step by step: create a password file with mosquitto_passwd, restrict topics with an ACL file using %u and %c, and enable TLS on 8883.
GuidesMQTT Security Best Practices: A Practical Checklist
Secure MQTT step by step: TLS, authentication with passwords, certificates or tokens, topic ACLs, client ID rules, payload encryption, rate limits, monitoring.
GuidesMQTT over WebSockets: Connecting from the Browser
MQTT over WebSockets explained: why browsers need it, ws vs wss, the /mqtt path, common ports, mixed content errors and a working browser example with MQTT.js.
Tutorials
How to Install Mosquitto MQTT Broker (Ubuntu, Debian, Windows, macOS)
Install the Mosquitto MQTT broker on Ubuntu, Debian, Windows or macOS, run it as a service, test it with mosquitto_sub/pub and fix the 2.x local-only mode.
TutorialsMQTT in Python with paho-mqtt: Publish & Subscribe Tutorial
Python MQTT tutorial using paho-mqtt 2.x: connect, subscribe and publish, loop_forever vs loop_start, QoS, TLS, username/password and automatic reconnects.
TutorialsMQTT in JavaScript: MQTT.js Tutorial for Node.js and the Browser
Learn MQTT in JavaScript with MQTT.js v5: connect, subscribe and publish in Node.js and in the browser over WebSockets, async/await, React and error handling.
TutorialsESP32 MQTT Tutorial with Arduino (PubSubClient)
ESP32 MQTT tutorial with Arduino and PubSubClient: connect to WiFi and a broker, publish sensor JSON, subscribe to commands, reconnect safely and enable TLS.
TutorialsRun Mosquitto in Docker (docker run & docker-compose)
Run the eclipse-mosquitto image with docker run or Docker Compose: config, data and log volumes, ports 1883 and 9001, plus a password file via docker exec.
TutorialsHome Assistant MQTT Setup: Broker, Integration & Discovery
Set up MQTT in Home Assistant: Mosquitto add-on or external broker, the MQTT integration, MQTT discovery config topics with a JSON example, and testing it.
TutorialsNode-RED MQTT: Connect, Subscribe and Publish
Use MQTT in Node-RED: configure the broker node, subscribe with mqtt in, publish with mqtt out, parse JSON, set dynamic topics and import a ready-made flow.
Fundamentals
What Is MQTT? A Practical Introduction
What is MQTT? A practical introduction to the MQTT protocol: brokers, topics, publish/subscribe, QoS, retained messages and Last Will — with hands-on examples.
FundamentalsMQTT Ports Explained: 1883, 8883, 8083, 8084 and 443
Which MQTT port should you use? Learn what ports 1883, 8883, 8083, 8084 and 443 mean, which work in a browser, and the exact ports of popular public brokers.
FundamentalsMQTT QoS Levels Explained: QoS 0, 1 and 2
MQTT QoS explained: how QoS 0, 1 and 2 work packet by packet, what the downgrade rule means, how sessions affect delivery, and which QoS level to choose.
FundamentalsMQTT Topics and Wildcards: Design Guide and Best Practices
MQTT topics and wildcards explained: topic levels, the + and # wildcards, $SYS topics, shared subscriptions and best practices for designing a topic hierarchy.
FundamentalsMQTT Retained Messages: How They Work and How to Clear Them
MQTT retained messages explained: how the retain flag works, when to use it, how to clear a retained message with an empty payload, and MQTT 5 retain options.
FundamentalsMQTT Last Will and Testament (LWT) Explained
How MQTT Last Will and Testament works: when the broker sends it, will delay in MQTT 5, and the retained online/offline presence pattern with code examples.
FundamentalsMQTT Keep Alive Explained: PINGREQ, Timeouts and Tuning
How MQTT keep alive works: the 1.5x timeout rule, PINGREQ and PINGRESP, MQTT 5 Server Keep Alive, NAT and mobile pitfalls, and how to choose a good interval.
FundamentalsMQTT Persistent Sessions: Clean Session vs Clean Start
Understand MQTT persistent sessions: cleanSession in 3.1.1, Clean Start and Session Expiry in MQTT 5, the Session Present flag and how QoS 1/2 messages queue.
FundamentalsMQTT Shared Subscriptions: Load Balancing with $share
Learn MQTT shared subscriptions: the $share/group/filter syntax, how messages are distributed, broker support, real use cases and pitfalls like ordering.
FundamentalsSparkplug B Explained: MQTT for Industrial IoT
Sparkplug B explained: the spBv1.0 topic namespace, NBIRTH/NDEATH and DATA/CMD messages, protobuf payloads, bdSeq and seq, and the primary host application.
FundamentalsMQTT 5 vs MQTT 3.1.1: What Changed and Should You Upgrade?
MQTT 5 vs 3.1.1 compared: reason codes, session and message expiry, user properties, shared subscriptions, topic aliases, request/response and flow control.
FundamentalsMQTT vs HTTP for IoT: Which Protocol Should You Use?
MQTT vs HTTP compared for IoT: push vs request/response, overhead, persistent connections, reliability and tooling — with a clear guide on when to use each one.