Closed topfs2 closed 5 years ago
The LWT is only sent out by the server if the client connection is lost unexpectedly - meaning without a proper disconnect. Since you're calling MQTTClient_disconnect
, you are getting a proper disconnect and the server is throwing away the LWT without sending it. Which is what it is supposed to do.
Try commenting out the MQTTClient_disconnect()
call and see what happens if you exit the application without cleanly disconnecting the client. In that case, the server should emit the LWT.
OMG thank you thank you thank you!
That explains why I got it to work in java, I didn't bother with the disconnect there :)
I have trouble getting last will and testament to work, it get it to work in paho for python and in java, but C version eludes me.
I've altered the code you have on your home page, with the minor addition of will as a connection option.
This I would expect should yield "online" and then "offline" when doing mosquitto_sub -t test -v
Here is the code with a cmake file if that makes it easier to test, I've just built paho c with
example.zip
Let me know if I should upload the example in some other fashion?