What’s Wrong with MQTT?

I have a very engaging, smart, talented friend, Luciano, who goes by the nickname Lucky. Lucky not only believes in MQTT, but he’s in love with it. He’d tell you it’s the magic bullet for moving data around the factory floor. In his mind, if you’re moving ASCII data or any control data, you should use MQTT. In fact, whatever the question is, MQTT is the answer.

He’s not all wrong. MQTT (MQ Telemetry Transport – previously was known as Message Queuing Telemetry Transport) is a very lightweight, publisher/subscriber messaging protocol that can move data from one machine to many machines in low bandwidth environments. It’s the perfect solution for applications that move a little bit of data from hundreds or thousands of sensors or machines over unreliable networks to clients distributed around the world.

Lucky’s not wrong. There are many benefits to using MQTT:

  • It’s lightweight. You can easily implement it in very resource constrained devices like temperature or pressure sensors, light bulbs, and the like.
  • It is reasonably simple to use with its publisher / subscriber messaging. The remote nodes publish data to a broker, and that broker organizes the data by “topics” and makes the data in those topics available to Clients.
  • It’s scalable. It works well for small numbers of nodes as well as large networks of nodes.
  • It solves the one-to-many problem that many other technologies struggle to implement.
  • It easily traverses firewalls.
  • MQTT provides separation between the producers of the data and the consumers of the data. The consumers don’t have to know anything about the producers – a benefit that paradoxically is also a detriment (see below).

Though it’s extremely popular and despite what people like Lucky might tell you, there are significant problems with using MQTT around the factory floor. It certainly doesn’t provide the kind of all-round functionality of an EtherNet/IP or PROFINET IO.

MQTT Offers No Interoperability
MQTT transfers data as a byte array. That’s it – just a series of bytes. Each user specifies the format of the data in the packet. There is no commonly accepted encoding to format the data and no commonly accepted mechanism to communicate that encoding to subscribers.

Just because you have a MQTT producer like a temperature sensor and a MQTT consumer like a small display device does not mean that you can easily transfer a temperature and display it. MQTT moves the bytes and does nothing to ensure interoperability. The temperature sensor may send the temperature as 16 bits of binary data encoded as a 16-bit unsigned integer, but the display device may expect XML. This kind of mismatch is common in configuring MQTT applications.

MQTT Provides No Data Discovery
Brokers organize messages using a UTF-8 Topic name string but provide no mechanism for Subscribers to search for relevant topic names. Subscribers must have some other mechanism to know the topic of interest to them. All subscribers, and there may be thousands of them, must be provided with the topic names using some other out-of-band mechanism.

Subscribers are Unaware of Status Changes in the Producers
If a producer repeats a message, MQTT brokers will send it to all subscribers even if it is duplicative of an earlier message. That’s useless bandwidth consumption.

Once MQTT publishes a message, it typically removes it from the topic. A new subscriber receives nothing if the publisher is offline. Worse, if the message retain flag is set, the new subscriber gets the last message sent by the producer – regardless of whether that message is hours, days, or weeks old.

MQTT is simply a brute force, unintelligent mechanism for moving messages.

MQTT Doesn’t Work For Battery Backed Devices
MQTT uses TCP, the connected messaging service. TCP connections need to be maintained, meaning any battery backed devices are unable to enter sleep mode.

MQTT Requires TLS for Security
MQTT is a TCP Application layer protocol and relies on TLS to provide encryption and security. Unfortunately, by adding TLS, MQTT is no longer a lightweight or low resource application.

Despite what my critics might claim, I am not entirely opposed to MQTT. But I am also not sleeping with bed sheets emblazoned with the MQTT logo like my friend Lucky. I’m just realistic about the best applications for this technology.

John