In this tutorial, we will discuss about the intro of Mosquittto MQTT broker. MQTT Broker is responsible for receiving network connections from the client and handling the client’s requests of Subscribe/Unsubscribe and Publish, as well as forwarding the messages published by the client to other subscribers.
MQTT Broker is useful in the industries of power, new energy, smart city, smart home, smart meter reading, vehicle networking, finance and payment, operators and so on.
Mosquitto is a lightweight open source message broker that Implements MQTT versions 3.1.0, 3.1.1 and version 5.0. It is written in C by Roger Light. It is available as a free download for Windows and Linux and is an Eclipse project. The MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.
The Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients. It is part of the Eclipse Foundation, is an iot.eclipse.org project and is sponsored by cedalo.com.
There are lot of other MQTT broker than Mosquitto eclipse, like EMQ X , VerneMQ, HiveMQ CE.
How it Works
As mentioned in the introduction, MQTT is a publish/subcribe messaging protocol. Clients will connect to the network, which can subscribe or publish to a topic. When a client publishes to a topic, the data is sent to the broker, which is then sent over all the clients.
Lets take one example, A topic might be “LivingRoom”, or “LivingRoom/Light” if you have multiple clients within that parent topic. The subscriber client will listen for incoming messages from the subscribed topic and react to what was published to that topic, such as “on” or “off”. Clients can subscribe to one topic and publish to another as well. If the client subscribes to “LivingRoom/Light”, it might also want to publish to another topic like “LivingRoom/Light/State” so that other clients can monitor the state of that light.
Installing the Mosquitto Broker
To use it, you will first need to install it: Mosquitto Broker
Installation of Mosquitto varies between different operating systems. However it is available for Linux, Mac, and Windows. Once installed you should have access to Mosquitto through your terminal. Starting it up should be as simple as entering mosquitto in your terminal. This is the simplest way to launch the Mosquitto broker on your computer. You can however specify a configuration file to use which configures settings for the Broker such as authentication.
How to install Mosquitto on Raspberry pi ?
Security
It is highly portable and available for a wide range of platforms. Go to the dedicated download page to find the source or binaries for your platform. Read the Change Log to find out about recent releases. Use the security page to find out how to report vulnerabilities or responses to past security issues. Setup Client authentication to Open, Basic, or fully functional TLS with x.509 certificates. This means you can make your Mosquitto Broker as Open or secure as you want. Don’t think Mosquitto is not secure, it is just as secure as any of the main stream cloud services.
Mosquitto Related Projects
Paho provides MQTT client library implementations in a wide variety of languages.
Streamsheets is an easy to use web based real time spreadsheet interface that can be used to process incoming data from a variety of sources, such as MQTT, OPC-UA, and REST. Developers and non-developers can use Streamsheets to control processes and build dashboards, for example. Mosquitto is a core component of Streamsheets.
web server to display data from ESP8266/ESP32 WiFi devices.