Comparison
Running an MQTT broker in the PLC or on a separate device
Short answer
No MQTT broker is ported to Automation Runtime, so the broker cannot run in the PLC's runtime today. Keep the working split: the Paho-based client in the controller and Mosquitto on an external Linux device, or a Linux guest on hypervisor-capable controller hardware when one box is mandatory. Porting Mosquitto or NanoMQ into the runtime is a software project, not an install.
On this page
Run the broker outside the controller. No MQTT broker is ported to Automation Runtime: paho.mqtt.c-ar is a client, and neither Mosquitto nor NanoMQ is published as a runtime port. The working arrangement is the Paho-based client publishing from the controller to Mosquitto on an external Linux device, on the standard MQTT ports. If one box per site is mandatory, the only same-hardware path is a Linux guest beside the runtime on hypervisor-capable controller hardware. The five options below are sorted by evidence status, a sizing example shows throughput is not the deciding factor, and every site type ends with a decision.
Client and broker are different jobs #
An MQTT client publishes and subscribes. A broker accepts TCP connections on port 1883 in plaintext or port 8883 with TLS, authenticates clients, holds session state, and routes every message between publishers and subscribers. Two different programs, and only one of them exists for this runtime.
The client side is solved: paho.mqtt.c-ar, the Automation Runtime port of Eclipse Paho's C client, is field-reported working for variable exchange out of the controller. The broker side has no counterpart. No MQTT broker is published as an Automation Runtime port, so a broker in the PLC is a porting project, not an installation.
The gap is not one ecosystem's. On CODESYS-based controllers the standard offering is likewise a client, the MQTT Client SL library on a CODESYS controller, and the MqttGdsConnector project for PLCnext controllers is a client too, pointed by default at a public test broker. That public broker is a lab aid, not a plant endpoint.
The five options side by side #
Sorted by what is demonstrated, not by what is conceivable:
| Option | Evidence status | What it takes | Consequence |
|---|---|---|---|
Paho client in the runtime (paho.mqtt.c-ar) |
Field-reported working | The existing library, no extra hardware | The controller is an MQTT endpoint; a broker is still needed somewhere |
| Mosquitto on an external Linux device | Field-reported working on a single-board computer, a router running OpenWRT and a virtual Linux server | One powered device per site | The baseline; adds a device, a power feed and a failure point per site |
| Mosquitto in a Linux guest on the controller | Proposed architecture, not a validated deployment | Hypervisor-capable controller; Linux general-purpose OS beside the runtime | One enclosure and one power feed; broker updates decoupled from the runtime |
| Mosquitto ported into the runtime | Candidate only, no port published | A porting project against the runtime's C environment | Not deployable today |
| NanoMQ ported into the runtime | Candidate only, no port identified | The same porting work on a smaller codebase | Not deployable today |
Rows one and two are what you can deploy this week. Rows four and five are software projects with no published result behind them.
Why the in-runtime port is a project #
Mosquitto is the credible candidate as porting work goes: a C/C++ codebase comparable in size to paho.mqtt.c, an extensive test suite to verify a port against, and build switches that reduce external dependencies toward a POSIX interface. Precedent exists, because OpenSSL and paho.mqtt.c itself were both ported to this runtime, so success is plausible.
Plausible is not installed. A real port has to confirm which POSIX interfaces the runtime exposes, fit the broker's memory and storage footprint, integrate it with runtime tasks, and handle sockets, startup, shutdown and message persistence. Mosquitto serves MQTT 5.0, 3.1.1 and 3.1 and takes POSIX signals for control actions, so even shutdown is a runtime-integration question. After it builds, the broker's own tests plus controller-level publish, subscribe, reconnect and restart tests all have to pass. No published port has done any of this, and a site's only message path is no place for an unvalidated broker.
Sizing: throughput is not what decides this #
An illustrative example with assumed inputs, not a measured result. A site of 12 machines, each controller publishing 10 messages per second with 200-byte payloads:
- 12 machines × 10 messages/s = 120 messages/s
- 120 messages/s × 200 B = 24,000 B/s = 24 kB/s of payload
- 24 kB/s × 8 bit/B = 192 kbit/s, about 0.19 Mbit/s on the wire before protocol overhead
- 0.19 Mbit/s on a 100 Mbit/s link is 0.19 ÷ 100 = 0.0019, about 0.2% utilization
Every Linux-class host in the table, single-board computer, router or hypervisor guest, carries 120 deliveries per second without working up a load. Nothing in this arithmetic pushes the broker into the PLC; the decision is about which deployment you can stand behind. Double the site to 24 machines and the wire load is 0.38 Mbit/s, still 0.4% of the same link.
One box per site: the Linux guest route #
When removing the external device is a requirement rather than a preference, the hypervisor arrangement is the only same-hardware option: controller hardware that supports a hypervisor runs the control runtime in one partition and a Linux general-purpose OS in the other, and Mosquitto installs in the Linux partition from its normal packages.
You gain one enclosure, one power feed, no separate device with its own failure mode, and the broker rides on hardware that has to run anyway. You accept that the broker is still not in the runtime but sits beside it, that only part of the controller range supports the hypervisor so it must be confirmed for the exact controller before specifying one, and that the Linux partition draws from the same CPU cores and RAM, so the controller must be sized for both. The compensation is operational: a Mosquitto update becomes a Linux package operation that never touches the control partition, where an in-runtime broker would update with the runtime itself.
Choosing the external broker device #
The baseline needs one external Linux device per site, and field reports cover three hosts: a Raspberry Pi-class single-board computer, a router running OpenWRT, and a virtual Linux server when the consumer sits off-site. The plant-floor version of the single-board computer is a fanless mini PC on DIN rail in the controller cabinet, powered from the cabinet supply, with no moving parts. Whether that broker receives publishes straight from each controller or from a gateway that aggregates several of them is a separate decision, argued in PLC MQTT direct publishing versus an IoT gateway.
Keep the plaintext listener inside the machine or cell network. Any connection that crosses a segment, toward IT, a DMZ broker or the cloud, runs on TLS, port 8883, with authentication and per-client access rules set from the first hour; a Mosquitto authentication and ACL walkthrough covers that configuration. For a hardened reference build, a secure Mosquitto lab broker with Node-RED is a good starting point. When the main subscriber is a SCADA platform, the shortlist widens to purpose-built commercial servers, and how Chariot and Mosquitto compare for Ignition SCADA is that comparison, but for controller-to-controller traffic inside a site, Mosquitto is the default.
Decision by case #
- The site already runs client plus external broker. Keep it, and spend the next effort on broker authentication, access rules and TLS rather than on eliminating the device.
- A new site must be one box. Specify hypervisor-capable controller hardware and run Mosquitto in the Linux guest, after confirming hypervisor support for the exact controller model.
- The broker must run inside the runtime. Fund it as a porting project, Mosquitto first, and keep the external broker as the fallback at every site until the port passes the runtime tests above. No site cutover waits on it.
- Every subscriber is central. Put one broker at the center and the per-site question disappears. A broker per site is required only when a local subscriber, a local SCADA, a local dashboard or machine-to-machine exchange, must keep running with the WAN down.
Questions asked
Can an MQTT broker run directly in Automation Runtime?
No published port exists. The Paho package for Automation Runtime is a client only, and neither Mosquitto nor NanoMQ ships as a runtime port, so a broker inside the runtime is a porting project until someone builds, publishes and validates one.
Does a Linux guest on the controller count as a broker in the PLC?
It shares the enclosure and the power feed, but the broker runs in a Linux partition beside the control runtime, not inside it. It requires a hypervisor-capable controller, and it is the only same-hardware way to run standard Mosquitto packages today.
Do I need an MQTT broker at every site?
Only if something local subscribes. When every consumer is a central SCADA or historian, one broker at the center serves all sites and no per-site device is needed. Local machine-to-machine exchange or a dashboard that must survive a WAN outage is what forces a broker per site.
Is plaintext MQTT acceptable on the plant network?
Inside one closed machine or cell network, plaintext port 1883 is normal practice. Any connection leaving that segment, toward IT, a DMZ broker or the cloud, runs on TLS port 8883 with authentication and per-client access rules on the broker.