MQTT Broker
Introduction
An MQTT broker is a server that receives all client messages and then routes the messages to the appropriate destination clients. An MQTT client is any device (from a microcontroller up to a fully-fledged server) that runs an MQTT library and connects to an MQTT broker over a network.
An open-source MQTT broker, LEAPS Mosquitto is a copy of docker image eclipse-mosquitto:1.5.11 with integrated custom mosquitto.conf
file located in /mosquitto/config/mosquitto.conf
.
For additional information, please see eclipse-mosquitto
Installation
System requirements
Note
Docker’s system requirements vary based on the operating system.
For Linux, you need a 64-bit architecture, compatible kernel version, and specific kernel features.
On Windows, use Docker Desktop on Windows 10 with virtualization enabled
On macOS, use Docker Desktop with macOS 10.13 or newer. In terms of hardware, a minimum of 2GB RAM is recommended, along with sufficient CPU and disk space.
Refer to Docker official documentation for up-to-date details.
Instructions
Install Docker on your PC
Install Docker Desktop on Linux
Additionally, you can refer to the following commands to install:
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh ./get-docker.sh sudo usermod -aG docker $USER
Open a command prompt or terminal window on your PC, then install the LEAPS Mosquitto Docker packages, run:
docker run -d -p 1883:1883/tcp -p 15675:15675 --name some_name leapslabs/leaps_mosquitto:latest mosquitto ---cfg /mosquitto/config/mosquitto.conf
where
some_name
is the name you want to assign to your container andtag
is the tag specifying theleaps-mosquitto
version you want.
Recommended run options
--user $(id -u):$(id -g)
Run the instance under a specific user and group.
--restart unless-stopped
Restart the instance automatically in case the server crashes.
The LEAPS Mosquitto installation process will begin.
For example, on Ubuntu (Linux):
docker run -d -p 1883:1883/tcp -p 15675:15675 --name leaps_mosquitto leapslabs/leaps_mosquitto:latest mosquitto ---cfg /mosquitto/config/mosquitto.conf Unable to find image 'leapslabs/leaps_mosquitto:latest' locally latest: Pulling from leapslabs/leaps_mosquitto f7dab3ab2d6e: Already exists 2a0a6c9fa787: Already exists a211eff771d6: Already exists d362e2a9c11b: Already exists Digest: sha256:a97752d6e2d81e2701c7cd5f807eb4256322983f8aa3135da8235b647e6a9b4e Status: Downloaded newer image for leapslabs/leaps_mosquitto:latest 1f526e755ad9a356c439003b93c200802628ae9bc046827e7327d0334804b565
Verify that the installation is successful, run:
For example, on Ubuntu (Linux):
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b1145b72db35 leapslabs/leaps_mosquitto:latest "sh -c 'cd /app && …" 37 seconds ago 11 seconds ago leaps_mosquitto
So, you have successfully installed and started LEAPS Mosquitto on your PC.
Getting started
LEAPS Mosquitto Docker
Start LEAPS Mosquitto, run:
docker start leaps_mosquitto
Stop LEAPS Mosquitto, run:
docker stop leaps_mosquitto
Restart LEAPS Mosquitto, run:
docker restart leaps_mosquitto
Remove LEAPS Mosquitto, run
docker rm --force leaps_mosquitto
Customized options
Mandatory options
port 1883 - default listener port
listener 1884 enabling listener at 1884
listener 15675 enabling listener at 15675
Recommended options
user mosquitto - Drop root priviledges
max_inflight_messages 200 - increase infighting QoS messages per client as few QoS1 could be sent at once.
max_queued_messages 1000 - increase the maximum number of QoS 1 and 2 messages to hold in a queue per client above those currently in-flight.
allow_zero_length_clientid true - allow client ID to be zero lenghth
persistent_client_expiration 14d - Auto protection from poorly designed clients
Troubleshooting
Use the following command
docker restart leaps_mosquitto
to restart LEAPS Mosquitto.Check the logs when the LEAPS Mosquitto is running, open the docker desktop, and select the leaps_mosquitto container.