In order to use MQTT you require an MQTT broker.
The broker (server) is the central hub of an MQTT network as shown in the diagram below..
When it comes to choosing an MQTT broker you have three main options:
- Use your Own Locally Installed Broker/Server
- Use a Cloud Based Sever or Virtual Server
- Use a Shared Server Application
Own Server Locally Installed
You can install an MQTT broker on your own server hardware including a raspberry Pi.
There are many brokers/servers to choose from, and most are free and open source.
Each of these brokers will have their own requirements e.g Aedes (formally Mosca) is a Node.js based and so requires node.js to be installed.
The table below lists the most popular brokers
|Mosquitto||Lightweight open source broker written in C. Probably the most popular MQTT broker. Supports MQTT v3.1.1 and v5
This is likely to be the default broker for edge networks.
Official Website Website
|Mosca- Now Aedes
||Mosca now Aedes is Node.js based and so requires node.js to be installed.See GitHub
It can also be installed as a node in node-red.
Aedes Replaces Mosca and Mosca is no longer being developed.
It is not very feature rich when compared to mosquitto but ideal for home automation projects.
Currently supports v 3.1.1
Runs on Windows and LInux
|Written in Erlang is Open Source and described as massively scalable.
EMQ Implements both MQTT V3.1 and V3.1.1 protocol specifications, and supports MQTT-SN, CoAP, WebSocket, STOMP . See Github
|Python Test Broker||Python test broker including MQTT v5 https://github.com/eclipse/paho.mqtt.testing/tree/master/interoperability|
|VerneMQ||Written in Erlang and supporting clustering.
|HiveMQ||HiveMQ CE is a Java-based open source MQTT broker that fully supports MQTT 3.x and MQTT 5.
They also provide an enterprise ready broker See https://www.hivemq.com/
and also a cloud version
and a public test broker
Note: Comprehensive comparison list on wiki
The problem with this arrangement is that you are responsible for the installation, and maintenance of the hardware and software.
This is likely to be the main choice for local MQTT applications and also ideal when testing or learning MQTT..
Mosquitto vs Mosca (now Aedes) for Learning and Testing
If you are just getting started with MQTT and you are also using node-red then you might want to use the Aedes broker.
Aedes/Mosca is a very simple broker and ideal for small home network deployments and for learning MQTT.
It is can be installed as a node-red node and then added to a flow.
Mosca (Aedes) supports websockets and also SSL.See Install Aedes Broker on Node-Red
However my test broker is mosquitto as it allows me to test all the different features of MQTT
Install Broker on a Virtual Server
These are available from many providers and are currently mainly used for website hosting.
However they can be used for hosting any web application, and will be a popular choice for hosting Node.js and MQTT in the cloud.
With this type of hosting you aren’t responsible for the hardware, but software install and management is your responsibility.
Online or cloud based MQTT servers/brokers are likely to be used for connecting different physical geographic locations together.
Google, Amazon, Microsoft, IBM and many others provide cloud based hosting.
Managed MQTT Servers/Brokers- Cloud Hosting
This is similar to cloud servers except you are limited to hosting a single application i.e MQTT.
This is very similar to the way present day websites are hosted.
This form of hosting is preferred for small organisations as the software install and maintenance is done by the hosting company.
Just as with standard web hosting there are likely to be a wide range of options available for MQTT hosting
Because the market is still very new there are very few dedicated commercial MQTT hosting providers.
Here are the ones I am currently aware of.
flespi is a new online broker offering free MQTT broker service and support MQTT v5. Currently there doesn’t appear to be a paid option.
myqtthub.com offers MQTT services and REST API support. It has lots of plans, including a free option, and also offers online message storage.
Beebotte -IOT Platform supports MQTT , Websckets and REST API. Provides a free tier for evaluation.
Online Test Brokers
These brokers are used for testing MQTT but a view offer commercial packages.
Online Cloud Base MQTT Brokers/Servers
|Broker Type||Broker Address and Port||Websocket Support||SSL support|
Encrypted port 8081
|Yes 8883 With Client certificate 8884|
80 and 443 (SSL)
Here are a few benchmark test results that you should find interesting.
In both case mosquitto came out wit the best performance, Mosca was surprisingly close.
Common Questions and Answers
Question – I have two locations do I need a broker in each location or should I use a cloud broker?
Answer – If you have only a few MQTT devices in each location then it would make sense to use a cloud based broker. If you have thousands then a local broker in each location would make more sense.
Question – Do I need to use SSL on my local broker?
Answer -If your network is private then I don’t think it is really necessary.
Question -Can I access my local broker from across the Internet?
All of the major cloud platform providers provide MQTT support and are likely to be the choice for enterprise organisations.
MQTT brokers as a service providers like cloudmqtt are likely to be the choice for smaller organisations that require MQTT between locations.
Almost all organisations are likely to deploy local brokers and the popular choice here is going to be mosquitto and for home automation I would think Aedes.
Both Aedes and mosquitto are small enough to run on very simple hardware like the raspberry PI.
Moving MQTT Providers
Because MQTT brokers don’t really store messages long term (unlike email) moving MQTT providers should be relatively easy.
Related Articles and resources:
- How to Install The Mosquitto MQTT Broker on Windows
- How to Install The Mosquitto MQTT Broker on Linux and AWS
- Setting Up a CloudMQTT broker
- MQTT and Websockets
- Mosquitto SSL Configuration -MQTT TLS Security
- MQTT for Beginners
- Public MQTT Brokers and Reserved Topics – Discussion Post