Mosquitto MQTT

What is Mosquitto MQTT?

Mosquitto MQTT is an open-source message broker that implements the MQTT (Message Queuing Telemetry Transport) protocol. Mosquitto is lightweight and is suitable for use on a wide range of devices ranging from low power single board computers to full servers.

The MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for real-time IoT (Internet of Things) messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers. Some of the factors you will need to consider when evaluating the best choice of MQTT broker for IoT use cases are covered, here: How to Choose the Best MQTT Broker For IoT? | Webbylab.

Mosquitto MQTT enables efficient, bi-directional communication by allowing devices to publish messages (such as sensor data) to specific topics and subscribe to topics to receive relevant information. It supports various QoS (Quality of Service) levels to ensure message delivery reliability and scalability.

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.

Mosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo.



How does Mosquitto MQTT work?

In MQTT there are a few basic concepts that you need to understand:

  • Publish/Subscribe - In a publish and subscribe system, a device can publish a message on a topic, or it can be subscribed to a particular topic to receive messages.
  • Messages - Messages are the information that you want to exchange between your devices. This can either be a command or data.
  • Topics - Topics are the way you register interest for incoming messages or how you specify where you want to publish the message.
  • Broker - The broker is primarily responsible for receiving all messages, filtering the messages, decide who is interested in them and then publishing the message to all subscribed clients.

In MQTT, a publisher (device/client) publishes messages on a topic and a subscriber must subscribe to that topic to view the message.

The Mosquitto MQTT Publish/Subscribe model


Using Mosquitto MQTT with IoT sensors and devices – Example: A smart fridge

Let's walk through how Mosquitto MQTT works using the example of a temperature sensor on a smart fridge:

  • Setup: First, let's imagine a smart fridge equipped with a temperature sensor. This sensor measures the internal temperature of the fridge at regular intervals.
  • Publishing Data: The temperature sensor periodically takes readings of the fridge's temperature. When it has a new reading, it publishes this data to a specific topic on the MQTT broker. In this case, let's say the topic is named "fridge/temperature".
  • MQTT Broker: The MQTT broker (in this case, Mosquitto MQTT) acts as a middleman or message broker between the temperature sensor (the publisher) and any devices or applications interested in receiving the temperature data (subscribers). The broker receives the temperature readings published by the sensor.
  • Subscribing to Data: Now, let's say there's a mobile app on your smartphone that displays the current temperature of the smart fridge. This app subscribes to the "fridge/temperature" topic on the MQTT broker.
  • Receiving Data: Whenever there's a new temperature reading published to the "fridge/temperature" topic, the MQTT broker forwards this data to all subscribers who have expressed interest in that topic. In this case, the mobile app receives the temperature data from the MQTT broker.
  • Displaying Data: The mobile app receives the temperature data and updates its interface to display the current temperature of the smart fridge to the user. The user can now see the temperature of their fridge in real-time, as reported by the temperature sensor.
  • Feedback Loop: If the user interacts with the app and adjusts the temperature settings of the smart fridge, the app can publish these changes back to another MQTT topic, such as "fridge/settings". Other devices or systems, like the smart fridge itself, can subscribe to this topic to receive and act upon the user's adjustments.

This process continues, creating a feedback loop where sensor data is published to specific topics, and various devices or applications subscribe to those topics to receive and act upon the data. Mosquitto MQTT facilitates this communication by efficiently managing the messaging between publishers and subscribers in a lightweight and scalable manner.


How is Mosquitto MQTT licensed?

Mosquitto MQTT is primarily licensed under the Eclipse Public License (EPL). This license is an open-source license that allows for the use, modification, and distribution of the software, both commercially and non-commercially, while ensuring that any modifications made to the original source code are also open-source and freely available to the community.

Full details of Mosquitto MQTT licensing can be found on the projects GitHub site: see: mosquitto/LICENSE.txt at master · eclipse/mosquitto · GitHub.


Why monitor Mosquitto MQTT?

The high availability of topics and messages and the balancing of load across brokers are some of the reasons why Mosquitto MQTT brokers are widely used in mission-critical environments today. In such environments, sudden unavailability of the broker, irregularities in load balancing of topics, and slowness in delivery of messages, can significantly delay inter-application communication, badly hit user productivity, and negatively impact both user experience and revenue. To avoid this, administrators must closely monitor the availability and overall performance of the Mosquitto MQTT, proactively detect anomalies, and promptly initiate measures to pre-empt them. This is where eG Enterprise helps!

eG Enterprise is capable of monitoring Mosquitto MQTT out-of-the-box. eG Enterprise's intelligent agents can instantly detect and promptly alert administrators to issues in the uptime and performance of the MQTT by measuring the data sent/received through Publish mode and the messages sent/received on topics. Learn more: How Does eG Enterprise Monitor Mosquitto MQTT? (eginnovations.com).