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?
Asked
Active
Viewed 2,007 times
0

Amrmsmb
- 1
- 27
- 104
- 226
2 Answers
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
-
hi,do you think if the client called "disconnect", would that help to clear the "LWT" retained? – Amrmsmb Nov 14 '14 at 16:57
-
No, nothing apart from publishing an empty payload to the same topic will clear a retained message – hardillb Nov 14 '14 at 17:07
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
-
You linked the MQTT-SN specification which is different from standard MQTT, so this won't help the OP much. In case of MQTT-SN this will delete the WILL, though :) – Dominik Obermaier Nov 14 '14 at 16:46
-