MQTT Brokers
Message Queuing Telemetry Transport (MQTT) is a lightweight publish and subscribe protocol designed for constrained devices and unreliable networks. Every MQTT system is built around a broker: a server that receives the messages publishers send it, and delivers each one to the subscribers that have asked for it.
Publishers and subscribers do not connect to each other directly. A publisher sends a message to the broker and is finished; a subscriber receives it whenever the broker delivers it. Neither one needs to know that the other exists, be online at the same time, or share a network route. That decoupling is what makes MQTT a practical way to collect data from many small gateway devices, from equipment on isolated plant networks, and from sites that only allow outbound connections.
GENESIS connects to an MQTT broker as a publisher, as a subscriber, or as both at once. In Workbench, you define each broker once under Data Connectivity > Internet of Things > MQTT Brokers, and then reference it from the publisher and subscriber connections that use it. Learn more
Topics and Wildcards
Messages are addressed to a topic, a slash-delimited string such as plant1/line3/oven/temperature. Topics are not created in advance and the broker does not validate them. A publisher simply names one, and any subscriber whose subscription matches receives the message.
A subscription may match more than one topic by using wildcards:
-
**
+** matches exactly one topic level.plant1/+/oven/temperaturematches the oven temperature on every line. -
**
#** matches all remaining levels and must be the last character in the topic.plant1/#matches everything published underplant1.
Because the topic string is the only addressing a message carries, the topic tree is effectively the namespace of the system. Designing it deliberately—one branch per site, area, and device, with the device identifier at a known level—is what allows a subscriber to be pointed at one branch and pick up every device beneath it.
Quality of Service
Each message is published with a quality of service (QoS) level that determines the delivery guarantee:
|
Level |
Name |
Behavior |
|---|---|---|
|
0 |
At Most Once |
The message is sent once and not acknowledged. It may be lost if the connection drops. |
|
1 |
At Least Once |
The message is retried until acknowledged. It arrives, but may arrive more than once. |
|
2 |
Exactly Once |
A handshake guarantees a single delivery. The most reliable and the most costly in terms of bandwidth and latency. |
Session and Connection Behavior
Several broker settings govern what happens when a connection drops and is re-established:
-
Client ID—Identifies the connection to the broker. It must be unique across everything connected to that broker; two connections sharing an ID disconnect each other repeatedly.
-
Clean Session—Determines whether the broker discards a subscriber's subscriptions and queued messages when it disconnects. When cleared, the session is durable: subscriptions survive the disconnect and QoS 1 and QoS 2 messages are stored until the subscriber returns.
-
Keep Alive Period—The interval at which GENESIS tells the broker it is still there. If the broker hears nothing within the period, it treats the connection as dropped.
-
Retained messages—A message published with the retain flag is stored by the broker as the last known value for its topic and delivered immediately to any subscriber that connects afterward. Without it, a new subscriber sees nothing until the next update is published.
Birth and Will Messages
Because a publisher and a subscriber are decoupled, a subscriber has no direct way to tell whether a silent publisher is idle or gone. MQTT solves this with two messages defined when a connection is opened:
-
A birth message is published on connecting, announcing that the publisher is online.
-
A will message is registered with the broker at connection time and published by the broker on the publisher's behalf if that connection drops ungracefully.
GENESIS can send both on behalf of an MQTT broker connection, with the topic, QoS, retain flag, and message body configured on the broker. Retaining the birth and will messages lets a subscriber determine the state of a publisher as soon as it connects.
Security
MQTT itself carries no security, so a broker connection is secured at the transport and authentication layers:
-
Protocol—GENESIS connects over plain MQTT (
mqtt:), secured MQTT (mqtts:), WebSockets (ws:), or secure WebSockets (wss:). The WebSocket options carry MQTT over the ports already used for web traffic, which often avoids new firewall rules. -
Security Mode—Selects the TLS version used for a secured connection. Use TLS 1.3 where the operating system supports it, otherwise TLS 1.2. is available for legacy brokers.
-
Certificates—GENESIS first validates the broker's certificate against the operating system's trust store. If that succeeds, nothing further is needed. If it fails, GENESIS falls back to the certificate named by Certificate identifier, and accepts the broker when that certificate appears in the chain the broker presented. If no CA certificate is supplied, the connection is refused.
The certificate does not have to come from a public certificate authority. Select the root certificate of your own internal authority, or, for a broker using a self-signed certificate, that certificate itself. A client certificate can also be selected where the broker authenticates clients by certificate.
Certificates are referenced from the machine's Trusted Root Certification Authorities store. A certificate held only as a file has to be imported there before GENESIS can select it.
-
Credentials—A user name and password can be supplied for brokers that authenticate that way. Individual publisher and subscriber connections can override the credentials configured on the broker, so several GENESIS connections can share one broker definition under different identities.
Use mqtt: or ws: only on a trusted, isolated network. These protocols send credentials and payloads in unencrypted communications.
Sparkplug B
Plain MQTT standardizes the transport but says nothing about the payload or the topic structure, which is why connecting to an unfamiliar device usually means describing its message format to GENESIS. Sparkplug B is a specification layered on MQTT that fixes both, so that any compliant device can be read without a custom decoder. Learn more