New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mosquitto sends LWT when persistent client restarts #1273
Comments
Further, when the client crashes before disconnecting, Mosquitto logs:
But does not send the LWT. It only sends the LWT on the next connection of a client (either Python or |
It is possible to reproduce with
When terminating |
Good find! Is there a way to gracefully terminate I guess these are multiple problems:
|
Experiencing the same behaviour, persistent clients fire their LWT message after reconnection |
Thanks for all the details everyone, I've just pushed a change that fixes all those points. You can try it on the |
Just a head-up that I also consider the bug fixed. I tested the fixes branch and it shows the expected behaviour. On a side note: This bug was actually a regression, it worked fine 1.5.8. |
* Fix Will message for a persistent client incorrectly being sent when the client reconnects after a clean disconnect. * Fix Will message for a persistent client not being sent on disconnect. * Fix mosquitto_pub not using the `-c` option. Thanks to Yannic Schröder. Closes eclipse#1273.
* Fix Will message for a persistent client incorrectly being sent when the client reconnects after a clean disconnect. * Fix Will message for a persistent client not being sent on disconnect. * Fix mosquitto_pub not using the `-c` option. Thanks to Yannic Schröder. Closes #1273.
I am trying to use LWT with a persistent client (
clean_session=False
). When this client disconnects cleanly and then is started again later, its LWT will fire when connecting.This is my example code with the Paho Python client:
I also tried to reproduce this script as closely as possible with
mosquitto_pub
:Reproduction:
foobar_topic
:mosquitto_sub -h localhost -t "foobar_topic"
foobar online
foobar crashed
andfoobar online
In the last step I expect the subscriber to only see
foobar online
as I correctly disconnected from the broker (according to the Mosquitto log).If I try the same with the listed
mosquitto_pub
command afterwards, I also get thefoobar crashed
message on the first run, consecutive runs only printonline
.I am not entirely sure if the bug lies within the Python library or Mosquitto. It is somewhat strange, that the last will fires on the first run of
mosquitto_pub
. However, I cannot reproduce the problem with only usingmosquitto_pub
. After a short investigation with Wireshark I found thatmosquitto_pub
is ignoring the--disable-clean-session
and sets the flag even when told not to do so.As this happens exactly when a new client with id
foobar
connects, independently of being Python ormosquitto_pub
, I believe the problem lies within Mosquitto. The persistent Python client exited cleanly and thus Mosquitto should not have published any LWT. Or am I missing something?Mosquitto Version: 1.6.2
The text was updated successfully, but these errors were encountered: