|[mosquitto-dev] last will from mosquitto_pub - how to get it sent out?|
Hi all,I'm trying to figure out how last will messages work with mosquitto_pub and when it will be sent. I did not find any useful example on this. As far as I understand, the connection will be properly closed immediately after publishing a message from the command line using mosquitto_pub and therefore the last will message will never be sent.
In my scenario, I'm publishing values to a broker and would like to inform the subscribers when the publishing device goes down. So I have tried something like
mosquitto_pub -h test.mosquitto.org -r -t testbench/willTest -m "stillAlive" -k 5 --will-topic testbench/willTest --will-payload "died" --will-retain
The will payload is never being sent out to the subscribers. Not even after I shut down the publishing device. This might even be expected behaviour, but how will this last will of mosquitto_pub be of any use then? Or am I missing out a point here?
If so, is there any other way to inform the broker that the publishing device has gone down than to also subscribe to some topic from the publishing device and giving a last will to mosquitto_sub? This would add additional complexity (and traffic) since I would have to monitor the state of the subscription.
Back to the top