The sys admin's daily grind – Mosquitto
No Insect Bites

Sys admin Charly does not tend toward hostilities, but he has huge problems with mosquitoes. Despite this, he does make an exception for the Mosquitto message broker.
I recently read that around 100 species become extinct every year. So why not mosquitoes? I am merciless on the issue, because I happen to be allergic to their stings. I can't sleep, with just one of these pests buzzing around my bedroom. My weapon of choice – always at hand to decimate the population of my enemy – is a 30-year-old school atlas beside the bed. But it is still a Sisyphean task.
And the bloodstains on the wallpaper also impact on the kind of atmosphere that I would like have in my bedroom, which explains why I repaper the walls nearly every year. I also failed to secure a majority vote in the family council for my suggestions of adopting mosquito-eating spiders or using a Linux and LiDAR (light detection and ranging) based mosquito laser. War is always miserable.
You will thus understand that my response to a piece of software named after these flying bloodsuckers was somewhat skeptical. However, this much I will reveal in advance, Mosquitto [1] is allowed to stay. The tool was given its name, because the developer wanted to have the letters MQTT in there somewhere, as the acronym for message queue telemetry transport. And telemetry is the right keyword for describing Mosquitto's task.
Mosquitto operates a messaging hub; in MQTT speak, this is known as the message broker. Any client wanting to communicate sends its message to the broker (publisher), and all clients that have a subscription with the broker (subscribers) then receive the message. The broker is simply named mosquitto
and runs as a daemon; the clients that publish and subscribe go by the names of mosquitto_pub
and mosquitto_sub
.
First, I start the broker. It normally runs in the background, but I can also stop the daemon and start it in the foreground on the console. Because Mosquitto runs on port 1883, I don't even need root privileges to do this:
mosquitto -v
The -v
parameter sets a higher verbosity level, so that I can send to the broker at work. Then I use the mosquitto_sub
client to subscribe to a topic. The topic is freely selectable and should ideally describe the type of data that you can expect in a meaningful way. As an example, I can subscribe to the topic date
:
mosquitto_sub -h 127.0.0.1 -i subscriber -t date
The -i
parameter describes the client's identity and is freely definable. I used subscriber
here; in a practical application, however, it would make more sense to use the client's hostname.
Mosquitto News
Time to publish something. On another console, I typed the following:
mosquitto_pub -h 127.0.0.1 -i publisher -t date -m "30.02.2017 ;-)"
See Figure 1. The text passed in with -m <text>
immediately appears on the console where mosquitto_sub
is waiting for data.

Impressively simple, don't you think? In daily use, topics are often hierarchically organized; users separate the hierarchy levels with a slash, as in: readings/humidity/outdoor
. You can secure communication with TLS and also stipulate that the server and clients identify themselves with certificates. I must admit: Mosquitto is useful. But my atlas is still staying where it is!
Infos
- Mosquitto: https://mosquitto.org
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
News
-
KaOS 2022.06 Now Available With KDE Plasma 5.25
The newest iteration of KaOS Linux not only adds the latest KDE Plasma desktop but sets LibreOffice as the default.
-
Manjaro 21.3.0 Is Now Available
Manjaro “Ruah” has been released and includes the latest Calamares installer, GNOME 42, and much more.
-
SpiralLinux is a New Linux Distribution Focused on Simplicity
A new Linux distribution, from the creator of GeckoLinux, is a Debian-based operating system with a focus on simplicity and ease of use.
-
HP Dev One Linux Laptop is Now Available for Pre-Order
The System76/HP collaboration Dev One laptop, geared toward developers, is now available for pre-order.
-
NixOS 22.5 Is Now Available
The latest release of NixOS with a much-improved package manager and a user-friendly graphical installer.
-
System76 Teams up with HP to Create the Dev One Laptop
HP and System76 have come together to develop a new laptop, powered by Pop!_OS and aimed toward developers.
-
Titan Linux is a New KDE Linux Based on Debian Stable
Titan Linux is a new Debian-based Linux distribution that features the KDE Plasma desktop with a focus on usability and performance.
-
Danielle Foré Has an Update for elementary OS 7
Now that Ubuntu 22.04 has been released, the team behind elementary OS is preparing for the upcoming 7.0 release.
-
Linux New Media Launches Open Source JobHub
New job website focuses on connecting technical and non-technical professionals with organizations in open source.
-
Ubuntu Cinnamon 22.04 Now Available
Ubuntu Cinnamon 22.04 has been released with all the additions from upstream as well as other features and improvements.