MQTT Broker&Client
The Heart of IIoT: MQTT Protocol, Broker, and Client Concepts
In the world of the Industrial Internet of Things (IIoT), transporting data from one point to another quickly, securely, and with low bandwidth consumption is critical. The most popular communication protocol meeting this need is MQTT (Message Queuing Telemetry Transport).
In this article, we will take an in-depth look at the cornerstones of the MQTT architecture: the Broker and the Client.
1. What is MQTT and How Does It Work?
MQTT is a messaging protocol based on the Publish/Subscribe model. Unlike the traditional client-server model, devices do not communicate directly with each other. Instead, all traffic is managed through a central intermediary known as the Broker.
Key Terms:
-
Topic: The addresses where messages are categorized (e.g.,
factory/line1/temperature). -
Payload: The actual data being sent (e.g.,
24.5). -
QoS (Quality of Service): The level of guarantee for message delivery.
2. What is an MQTT Broker?
The MQTT Broker is the central nervous system of the setup. It is the server where all messages are collected, filtered, and distributed to the correct recipients.
Responsibilities of the Broker:
-
Message Filtering: Tracks which client is subscribed to which topic.
-
Message Distribution: Forwards a message received from one client to all other clients subscribed to that topic.
-
Session Management: Manages disconnected devices and "Last Will and Testament" messages.
-
Security: Handles username/password authentication and checks SSL/TLS certificates.
Popular Broker software: Mosquitto, HiveMQ, EMQX.
3. What is an MQTT Client?
Every endpoint in the MQTT network is a Client. A client can act as both a data sender (Publisher) and a data receiver (Subscriber) simultaneously.
Types of Clients:
-
Sensors/PLCs: Usually on the "Publishing" side of the data (e.g., a humidity sensor).
-
Software/Dashboards: Usually on the "Subscribing" side, visualizing the data.
-
Gateway Devices: Devices like Hubbox collect Modbus or PLC data from the field and forward it to the Broker as an MQTT Client.
4. Why Use MQTT?
-
Low Bandwidth: Message headers are very small (minimum 2 bytes), providing a cost advantage in cellular (4G/LTE) connections.
-
Bi-directional Communication: It is very easy to both send data from the device to the cloud and send commands from the cloud to the device.
-
Scalability: A single Broker can manage thousands of different clients simultaneously.
-
Reliability: It features mechanisms to prevent data loss even in weak network connections.
5. Hubbox and MQTT Integration
Hubbox Connect devices can function as powerful MQTT Clients that convert field protocols (Modbus TCP, FINS, Siemens S7, etc.) into MQTT.
Thanks to the integrated Node-RED interface, you can:
-
Read PLC data,
-
Format this data into JSON,
-
Securely publish it to a local or cloud-based MQTT Broker.