Setup Mosquitto to treat all messages as retained

Hello. I am using Mosquitto broker and tty2mqtt as a serial bridge. The problem is that this bridge is not able to send a retained messages. My question is it possible to set up Mosquitto to treat all incoming messages as retained?

Assuming you are using Mosquitto 2.0.x, the answer is yes!

I’ve just created an example plugin that does this: mosquitto/plugins/examples/force-retain at develop · eclipse/mosquitto · GitHub

If you’re on Linux and happy with compiling things, then the following command line commands should work:

git clone
cd mosquitto
git checkout develop
cd plugins/examples/force-retain
sudo cp /usr/local/lib

Then add the following to your mosquitto.conf:

plugin /usr/local/lib/

If you need help with any of the compiling stage please let me know.



Hello Roger,

Thank you very much for the quick response with the solution. I use Mosquitto 2.0 on Linux. But, the thing is the developer of the tty2mqtt Siegfried Steiner has implemented retained flag in the bridge.
I am sure, this plugging will be useful for someone else.
Really appreciate your help/