A Guide to MQTT Messaging Brokers and Client Software
By Susannah Brodnitz / Sep 11, 2022 / InfluxDB, Iot
MQTT is a machine-to-machine communication protocol. Devices publish messages to a broker under specific topics, and other devices subscribe to those topics to receive information. It’s popular because it doesn’t take up a lot of bandwidth, so IoT devices with limited network connectivity can use it. MQTT works because of brokers. Each device sending and receiving data can communicate with potentially millions of other devices while only connecting to one broker. There are several different brokers developers can choose from, some open source and some commercial. Devices need to run client software to connect to a broker. This post is an overview of some of the most popular brokers and client software.
MQTT brokers connect to client devices, authenticate connections, and temporarily store data. Because each device only connects to the broker, it is easy to add new devices into an architecture as projects scale. Each device can have access to complex data from countless other devices even if it only has limited bandwidth, which makes MQTT an ideal protocol for many IoT applications. MQTT brokers can either be managed, meaning you don’t need to install anything on your server, or self hosted, in which case you set up the broker on your own server and manage security and scaling as necessary for your application. Broker examples are listed below:
Mosquitto is one of the most popular MQTT brokers. The Eclipse foundation supports it, along with the popular Paho MQTT client libraries. Celado, the company behind the Eclipse foundation, also offers a Pro Mosquitto option that includes hosting and high-availibility.
EMQX, another open source MQTT broker, is cloud native and was the first broker to support MQTT version 5. EMQ, the company that created it, states that an EMQX cluster of brokers can handle 100 million subscribers. In addition to the broker, EMQ created the open source MQTT tools NanoMQ and Neuron to connect IoT devices to the cloud.
HiveMQ is another broker option. The company has both an open source broker and a hosted broker that works especially well for scaling applications and integrates smoothly with InfluxDB.
AWS IoT Core is a popular commercial managed broker. It also works well for scaling and is convenient for developers who already use AWS.
Azure IoT Hub is another good managed option for developers who use Azure.
Popular client software
Devices that publish messages to brokers or subscribe to topics are called clients. To do this, they need to run client software that connects to a broker using login information. One popular open source client tool is MQTT X, which EMQ supports. It works on MacOS, Windows, and Linux operating systems and uses a chatbox interface to send and receive messages. Many of the companies and organizations that have MQTT brokers also have client software. Mosquitto has an open source command line interface as well as C and C++ client libraries. The HiveMQ MQTT Client is Java-based and supports both MQTT version 5 and version 3.1.1. There are also many more open source MQTT tools and client libraries available on GitHub.
How InfluxDB fits in
IoT sensors collect time series data. There are huge amounts of it, and to build automation, developers need to be able to analyze it in real time. InfluxDB stores and queries this data efficiently and fits into MQTT data pipelines in a few different ways.
You can use the MQTT Consumer Monitoring Telegraf input plugin to collect data from a broker and send it to the output of your choice.
InfluxDB also partners with HiveMQ for analysis and visualization with the Sparkplug extension.
You can also use the MQTT Producer Telegraf Output Plugin to send data back to a broker after analyzing and querying it in InfluxDB. This step is very powerful and gives IoT devices the transformed data necessary for complex automation. Developers use MQTT for many kinds of applications that require machine-to-machine communication, from smart home devices to industrial manufacturing, and choosing which broker and client software to use is the first step to getting your project up and running.