MQTT Broker Implementation

I am using MQTT to exchange variables with the outside world. For this I am using this excellent Paho implementation successfully: GitHub - br-automation-com/paho.mqtt.c-ar: MQTT Client for Automation Runtime based on eclipse/paho.mqtt.c

To minimize the number of devices required in my setup I would like to integrate a simple MQTT Broker into the PLC. Does anyone know of a decent implementation which can be ported or is there a ported version already somewhere?
Any pointers are highly aprecciated!

Hi Gerald,

I’m not a expert, but I don’t think that there’s a already existing port of a MQTT broker for Automation Runtime.
I personally use the Mosquitto MQTT broker running on a rented Virtual Linux Server.

One idea could be using a Hypervisor with AR and Linux as GPOS system, and install the broker in the GPOS. But then you need a hypervisor suitable hardware (APC / PPC).
Of course, then the broker is also not running in AR, but at least on the same hardware device.

The system is based on a X20CP1586. Right now I am running Mosquitto on a Raspi to do the job, but I like to eliminate this to save cost.

Maybe somebody has ported a broker like this NanoMQ: An Ultra-lightweight MQTT Broker for IoT Edge already.

I actually think that the broker is a good candidate to port. It is very extensively used, it has tons of test cases that can be used to verify the porting, and its all written in c/c++. The size of the codebase is similar to the, and from what I can tell, it has switches to disable external build dependencies, meaning dependencies will be towards a POSIX interface.

The only problem is that you need to port it. Because this has been done before for openssl and paho-mqtt, I don’t expect such an endeavor to be all too dramatic - but then again, it still needs to be done.


I was afraid that you would say that; porting such a large codebase is beyond my capabilities. So if nobody has done this before, I guess I am stuck with the idea and stick with the good old external broker.
Thank you, though and thank you for your wonderful Paho port!

1 Like

Well, for all it´s worth - the seed has been planted :slight_smile:

An alternative to a Raspberry Pi would be an OpenWRT router which is also able to run the Mosquitto broker and there are plenty of cheap devices available.

How does your setup actually look like?
Do you need an MQTT broker on each site?

Yes, I would need the broker on each site and I know that it would be able to run the broker on cheap devices (even down to an ESP32). But each device needs power and can be defective. The PLC needs to run in any case and therefore this would make a more robust system.