What is Eclipse Mosquitto (MQTT)?

Eclipse Mosquitto

Eclipse Mosquitto is an open-source message broker that complies with the EPL/EDL license and supports MQTT versions 5.0, 3.1.1, and 3.1.

Mosquitto executable uses about 3MB of RAM while there are 1000 clients connected.

Mosquitto has a bridge that enables connections to other MQTT servers, including other Mosquitto instances.

What is MQTT?

The Internet of Things uses MQTT, an OASIS-recognized messaging standard. MQTT is an abbreviation for “MQ Telemetry Transport.”

By using a publish/subscribe approach, the MQTT protocol offers a simple way to conduct messages.

Basic concepts of MQTT

  • Publish/Subscribe - A device may publish a message on a particular topic or subscribe to a specific topic to receive messages.

  • Messages - The information we want to transfer between our devices is contained in messages.

  • Topics - Using topics, we can indicate where to post a message or our interest in receiving incoming communications.

  • Broker - The broker’s primary responsibility is to receive all communications, filter them, determine who is interested in them, and then send the message to all clients who have subscribed.

MQTT publish/subscribe model
MQTT publish/subscribe model

Syntax

The command for connecting to a host and subscribing to a topic using mosquitto_sub has the following syntax:

mosquitto_sub -h <hostname> -p <port> -u <username> -P <password> -t <topic>

hostname: An Internet host, or website, is recognized by a hostname.

port: In networking, a port is a numerical identifier assigned by software to a network protocol and used to receive or transmit data for a particular service.

username & password: A username or password that is used by someone who has access to a computer, network, or online service.

topic: Where to send a message or our interest from where to recieve a message.

Note: When deploying mosquitto_sub, pass the -d parameter to view the subjects on which messages are published. For Example:

mosquitto_sub -h "thethings.example.com" -p "1883" -u "app1" -P "NNSXS.VEEBURF3KR77ZR.." -t "#" -d

Free Resources

HowDev By Educative. Copyright ©2025 Educative, Inc. All rights reserved