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 https://github.com/eclipse/mosquitto
cd mosquitto
git checkout develop
cd plugins/examples/force-retain
make
sudo cp mosquitto_force_retain.so /usr/local/lib
Then add the following to your mosquitto.conf:
plugin /usr/local/lib/mosquitto_force_retain.so
If you need help with any of the compiling stage please let me know.
Regards,
Roger
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/
Hello, I followed your steps to put the plugin on my broker server. However, I’m getting an error when starting my broker server after i added the plugin to my .conf file:
1716971979: mosquitto version 2.0.11 starting
1716971979: Config loaded from /etc/mosquitto/mosquitto.conf.
1716971979: Loading plugin: /usr/local/lib/mosquitto_force_retain.so
1716971979: Error: Unable to load auth plugin “/usr/local/lib/mosquitto_force_retain.so”.
1716971979: Load error: /usr/local/lib/mosquitto_force_retain.so: undefined symbol: mosquitto_plugin_set_info
I would be grateful if you could help me with that. Thank you.