Message Queuing Telemetry Transport (MQTT) is the standard protocol for the internet of things (IoT), enabling lightweight and efficient communication for remotely-connected devices. Such devices often include smart monitors, sensors, wearables, smart lighting, thermostats, security and recording systems, and more. 

MQTT often requires an intermediary device (called a "broker") to transport data back and forth—either locally or remotely. The protocol is known for being reliable and has seen numerous iterations following its 1999 debut via IBM. It later became an OASIS open standard in 2014 (and an ISO standard) and is built atop the TCP/IP stack for improved compatibility with a wide variety of IoT devices.

What makes MQTT useful?

The MQTT protocol was initially built to connect arrays of active sensors across oil pipelines with satellites, allowing for easier monitoring. Once this application proved useful, the scale of MQTT's adoption rose steadily in lockstep with rising IoT popularity. It's now used across the automotive, smart home, manufacturing, logistics, and telecommunications industries—to name a handful of examples. 

The MQTT protocol has the numerous benefits: 

  • A lightweight and efficient design

  • Reliable message delivery with configurable quality of service (QoS) levels

  • Bi-directional communication

  • Support for mobile networks, unreliable networks, and smoother session persistence

  • Support for high latency networks with limited bandwidth

  • Massive scalability to millions of devices concurrently

  • Easy message encryption and authentication support

Because MQTT use spans so many industries and use cases, the protocol was designed to support both high-powered and low-powered hardware. A number of vendors offer MQTT broker instances for IoT applications, each with unique system requirements in order to run effectively. 

MQTT's development is also ongoing. Later versions have added important enhancements to scalability, error reporting, overall performance, extensibility, and device discovery. While we can't accurately forecast what future MQTT versions will bring, it's a safe bet that those developments will mirror shifting needs across the IoT landscape.

How does MQTT work?

While we equate MQTT with "messages" both functionally and by name, communication works a little differently than that of other internet protocols, such as HTTP. MQTT uses a publish and subscribe mechanism to transmit messages between devices. IoT devices subscribe to a given "topic," which is a UTF-8 encoded string that filters messages for a client or group. 

Say you've set up a smart thermostat at home. For users who monitor and control home temperature via their personal devices (such as a smartphone or tablet), it makes much more sense to subscribe to a temperature messaging stream instead of something irrelevant (like speed). Luckily, this topic exchange happens automatically once a user connects their smart devices. 

The subscribed device connects to an MQTT broker that communicates bi-directionally—which receives temperature data from the sensor (the publisher) and sends it onwards to connected applications. There's also a subscriber backend for added horizontal scalability. Later MQTT versions leverage this backend to enable subscription sharing between multiple clients.

haproxy-mqtt-diagram

MQTT uses TCP/IP port 1883 by default for communication, which is reserved for unencrypted message delivery. Meanwhile, MQTT can also use port 8883 for encrypted communication via SSL/TLS. The Internet Assigned Numbers Authority (IANA) has registered both ports for MQTT specialization. 

However, some vendor services and technical workarounds (due to a variety of reasons, such as network restrictions) can leverage port 443 for secure MQTT communication. This port also passes HTTPS traffic and may introduce extra congestion or latency at scale.

Does HAProxy support MQTT?

Yes! HAProxy products support the MQTT protocol and can be configured to ensure MQTT packet validity, inspect MQTT payloads, and return <fieldname> values as needed. Load balancing support for MQTT applications has existed since the release of HAProxy 2.4. 

To learn more about MQTT support in HAProxy, check out our Configuration Manual.