0
votes

I'm using Paho Java client currently, is it possible to trigger the broker to send the will message in code? since using disconnect() will not result in a will message being sent by the broker

2

2 Answers

0
votes

Try to kill client pid form terminal. This should trigger LWT after standard MQTT timeouts.

-1
votes

No, that's not how the LWT works.

The broker will only publish the LWT if the client times out (or the socket drops) without the client sending a disconnect message.

There is nothing to stop you manually publishing the same message before calling disconnect()