I have two RaspberryPis, one with the mosquito broker, and one acting as a client. The client has set up a LWT with the broker. After a power outage that affects both RPis, both RPis come back online, but the LWT is never sent. I expected it would be sent since from the broker's point-of-view, the client is not longer receiving pings. I am wondering if this is because mosquito does not persist LWT to disk (all my other retain messages are present)? If so, can I change mosquito to allow this?

My config looks like:

# Place your local configuration in /etc/mosquitto/conf.d/
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d
autosave_interval 300

1 Answer 1


LWTs are part of the session that mosquitto will persist to the db along with the rest of the session.

But if both the pi's fail due to a powercut then the broker will never get the chance to send the LWT as both will go offline at the same time as the client, so the keepalive timeout will never be reached.

It will not start the clock for any disconnected clients when it comes back online as keepalive is only valid for currently connected clients and no clients will be connected as it restarts.

So to answer the last question, no there is no way to get the behaviour you are looking for.

  • Thanks, hardillb, for the explanation of what's happening internally. Commented Jun 29, 2021 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.