What is MQTT (IoT, smart homes) --- an explanation under 120 lines or 1100 words

I was once reading about MQTT, IoT, and all sorts of "smart" homes (as if there were "dumb" homes anywhere).

Here I'll attempt to write the shortest and clearest introduction to MQTT.

It's good to know the history of computers. In the 1970s, text-based games were already popular, offering you to explore various dungeons.

Then computer networks emerged, and games became multiplayer, especially in the 1980s: MuD.

These games have a chat feature. You enter a (virtual) room, type a command like "say [to all] hello," and nearby players could read your words. They could reply.

And then people started coming to these games who were interested only in chatting, hanging out, but not in playing game itself. The rooms were like clubs, based on interests and topics. Players logged only for the chat.

A talker is a chat system that people use to talk to each other over the
Internet.[1] Dating back to the 1980s, they were a predecessor of instant
messaging. A talker is a communication system precursor to MMORPGs and other
virtual worlds such as Second Life. ... The early talkers were similar to MUDs,
with most of the complex game machinery stripped away, leaving only the
communication-level commands – hence the name "talker."[2] Ew-too was, in fact,
a MUD server with the game elements removed. ... Many of the online metaphors
used on talkers, such as "rooms"[3] and "residency," were established by these
early pioneering services and remain in use by modern 3D interfaces such as
Second Life.

( src )

In the late 1980s, IRC chats emerged, like crippled MuDs, without the gaming features. In the 1990s, IRC was popular. They are still used today (Freenode, and then Libera).

IRC is very primitive, with a ton of problems. The modern, popular incarnation is Discord, which supposedly fixed all these problems, but added a lot of disgusting visual candy and distracting popups. (Maybe Slack too, but I've used it not much.) Discord even has commands like in IRC (like "/command").

One attempt to fix the problems of IRC (and other messengers like ICQ) was XMPP/Jabber. Maybe not everyone aware, but Google Talk, for example, used this protocol. When I was using all these instant messengers in the 2000s and early 2010s, I had Miranda IM, and I connected to Google Talk, Facebook, VKontakte, and even LiveJournal via XMPP. It was enough to chat with the users of Facebook and VKontakte. Commercialization hit all these soc.networks hard, and as far as I know, no one allows connections via this protocol anymore. But it was convenient.

Also worth mentioning is rather obscure Juick, popular in the former USSR, which runs on XMPP.

So botnets, as far as I know, could be controlled via IRC in the old days. A bot on an infected computer logs into an IRC chat, a bunch of them gather in the room, and the bot operator posts commands to them in the chat. Which makes sense. Why reinvent the wheel when you can just set up an IRC server somewhere and let the bots connect? IRC protocol is primitive, and there were plenty of ready libraries, APIs. Chatbots like eggdrop, which perform certain actions in the absence of channel admins, like banning for flooding, automatically assigning operator status and so on, were also plentiful for IRC.

(Here's the term "botnet" in a more legal context: The bot also features a "botnet", which allows multiple bots to be linked together to share data and act in a coordinated fashion.)

Remind you of anything? Oh, yes. And that's where we start talking about MQTT.

MQTT is simply a chat server. The devices connecting to it are the users. The admin managing the devices simply posts commands. The devices listen. Devices can also post commands to other devices, again, through the chat server.

I realized this when I learned that MQTT has terms like "publish" and "subscribe". This terminology is borrowed from XMPP (but I wouldn't say for sure). The "publish" the is used instead of posting to a channel/room, the "subscribe" term is used instead of joining a channel/room.

(Pings in MQTT are the same as in IRC.)

It all makes sense -- the XMPP protocol is well-worn, has been actively tested/debugged, and was generally created by experienced guys, taking into account past mistakes/bugs. Besides, when was it developed? It was the late 90s, and most internet connections were dial-up, so poor network connections were taken into account. Why not reuse this experience? Connections with small IoT devices aren't very good either. It's not "fiber optic internet", after all.

A topic in MQTT is a channel/room. That's it. But in MQTT these channels can be nested, which makes sense. A topic might be something like "home/bedroom/fancy device/light bulb on a device."

And here's what distinguishes MQTT from chat servers: QoS, so you can see if a device's battery has died or if it's been moved off the range of a WiFi router.

Why is a server in MQTT called a "broker"? I don't know where it comes from, but this terminology is also used in netcat/ncat utility, which you can use to set up and run a simple chat server:

Connection Brokering

One of Ncat's most useful and unique abilities is called connection brokering.
A listening Ncat in broker mode accepts connections from multiple clients.
Anything received from one of the clients is sent back out to all the others.
In this way an Ncat broker acts like a network hub, broadcasting all traffic to
everyone connected.

Activate broker mode with the --broker option, which must be combined with
--listen. It wouldn't make sense for a client to be a broker. See the section
called “File Transfer” for details on using brokering to transfer files through
restrictive firewalls, and the section called “Chatting” for using brokering to
set up multi-user chat rooms. 

( src )

Think of MQTT server just as chat server, and this is it.

(By the way, the ejabberd server supports both Jabber and MQTT protocols. Coincidence? Not sure.)

But marketers can't use such simple and understandable terminology. They need to boost their reputation and tell everyone they've created something incredibly complex and revolutionary. Who will admit that they've created just another simple chat server, only better tailored for small devices? That's why they have to use obscure buzzwords.

But the MQTT protocol was deliberately designed to be primitive, so that it could be used by low-power, very cheap microcontrollers in very cheap devices.

(the post first published at 20251211.)


List of my other blog posts.

Subscribe to my news feed,

Some time ago (before 24-Mar-2025) there was Disqus JS script for comments. I dropped it --- it was so motley, distracting, animated, with too much ads. I never liked it. Also, comments din't appeared correctly (Disqus was buggy). Also, my blog is too chamberlike --- not many people write comments here. So I decided to switch to the model I once had at least in 2020 --- send me your comments by email (don't forget to include URL to this blog post) and I will copy&paste it here manually.

Let's party like it's ~1993-1996, in this ultimate, radical and uncompromisingly primitive pre-web1.0-style blog and website. This website is best viewed under lynx/links/elinks/w3m.