Aller au contenu principal
Aller au contenu principal

Software

MQTT broker

An MQTT broker is the central server that receives messages from publishers and distributes them to subscribers by topic. Examples: Mosquitto, EMQX, HiveMQ.

An MQTT broker is the server at the center of an MQTT system: devices and applications connect to it and publish messages to topics, and the broker forwards each message to every client subscribed to that topic. Publishers and subscribers never talk to each other directly. For installation and a comparison of brokers, see the complete MQTT broker guide.

How an MQTT broker works

The MQTT specification calls the broker the Server: the program that sits between clients that publish messages and clients that have subscriptions. Each client opens a connection to the broker, usually over TCP. IANA has registered port 1883 for plain MQTT and port 8883 for MQTT over TLS. Mosquitto, EMQX and HiveMQ also accept MQTT over WebSocket, which is what browser applications use.

The broker also handles:

  • Topic matching, with two wildcards for subscriptions: + matches one topic level and # matches any number of levels.
  • Retained messages: the broker keeps the last message published on a topic and sends it straight away to each new subscriber.
  • Persistent sessions: when a client reconnects, the broker delivers the QoS 1 and QoS 2 messages it missed.
  • Last Will: if a client drops without a clean disconnect, the broker publishes the will message that client registered when it connected.

Mosquitto, EMQX and HiveMQ

  • Eclipse Mosquitto is lightweight and licensed under EPL 2.0 / EDL 1.0. It runs on anything from a single board computer to a full server, but it has no clustering.
  • EMQX is written in Erlang and designed to run as a cluster. Versions up to 5.8 are Apache 2.0; since 5.9 (May 2025) it uses the Business Source License 1.1, which allows one node free in production and requires a commercial license for a cluster.
  • HiveMQ Community Edition is written in Java, licensed under Apache 2.0 and has no clustering; the commercial HiveMQ editions add it.

MQTT broker in Cloud Studio IoT

Each Cloud Studio IoT instance has its own MQTT server, with TLS on port 8883. Devices authenticate with a username and password managed in Gear Manager (Security > MQTT Configuration), publish to {MQTTUserID}/uplink/{DeviceAddress} and subscribe to {MQTTUserID}/downlink/{DeviceAddress} to receive commands. The MQTT integration docs walk through the setup. If you already run Mosquitto or EMQX, you can bridge it to the instance's MQTT server, as described in the EMQX integration.

Frequently asked questions

What is the difference between MQTT and an MQTT broker?+

MQTT is the protocol: the packet format and the rules for connecting, publishing, subscribing and acknowledging. An MQTT broker is the server software that implements the server side of that protocol and routes messages between clients.

What is the Mosquitto broker?+

Eclipse Mosquitto is an open source MQTT broker that implements MQTT 5.0, 3.1.1 and 3.1. It is light enough for a single board computer, but it does not support clustering.

Can I use a public MQTT broker in production?+

No. On public test brokers such as test.mosquitto.org, broker.emqx.io or broker.hivemq.com, anyone who subscribes to the same topic can read what you publish. Use them for tests and send production traffic to a broker you control, with TLS and authentication.

Related terms

Related articles