0

For testing, I have created a client with clean sessin = false and setWill(WILL_TOPIC, WILL_MSG.getBytes(), 1, true); and ran the App. Later, i set setWill(WILL_TOPIC, WILL_MSG.getBytes(), 1, false); when i run the App, i receive the previously reatined LWT messages. How to stop receiving them?

Amrmsmb
  • 1
  • 27
  • 104
  • 226

2 Answers2

3

You aren't receiving LWT messages as such, but a retained message. To clear a retained message, send a zero length retained message to the same topic. For example, with the Paho Python client you would do:

client.publish(WILL_TOPIC, payload=None, retain=True)
ralight
  • 11,033
  • 3
  • 49
  • 59
0

You could send a CONNECT message with “CleanSession=false” and “Will=true”, and sends an empty WILLTOPIC message

check this section 6.3

Amrmsmb
  • 1
  • 27
  • 104
  • 226