Open testark opened 7 years ago
Setup Last Will and Testament (optional). A broker will publish a message with qos = 0, retain = 0, data = "offline" to topic "/lwt" if client does not send keepalive packet.
Example Syntax mqtt:lwt(topic, message[, qos[, retain]])
@aaryadev thanks, but that won't solve my problem.
I have set esp8266 mqtt:lwt("iffline, "mydeviceid",0,0) and heartbeat time out is 10 sec so when esp8266 disconnects without mqtt.close() like network failure
mosca server will wait for 10 sec then trigger firebase cloud messaging to my phone
@aaryadev yes, but unfortunately that doesn't work on my scenario.
@testark What is your scenario.?
In my case, client (esp8266) often offline then online immediately, but the 'clientDisconnected' event always happen after 'clientConnected'. I change keepAlive from 60s to 15s or use lwt message but it still did not work. I think lwt message is slower than publishing disconnected message to subscribed clients inside 'clientDisconnected' event, because broker must load lwt payload from persistence (in my case is redis).
Is there any way to resolve my issue?
+1
Is there any way to detect that (some of) the target clients of a given QoS1 packet are offline and emit an event (such as
offline_message
) so that one can execute a custom action in such cases (like sending a notification or something)?