Commit ec6ed6f8 authored by dbaumgarten's avatar dbaumgarten Committed by Marcel Stör
Browse files

Better documentation for mqtt:lwt() (#2128)

parent 3e60fa8f
......@@ -151,6 +151,15 @@ This is the description of how the `autoreconnect` functionality may (or may not
Setup [Last Will and Testament](http://www.hivemq.com/blog/mqtt-essentials-part-9-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.
As the last will is sent to the broker when connecting, `lwt()` must be called BEFORE calling `connect()`.  
The broker will publish a client's last will message once he NOTICES that the connection to the client is broken. The broker will notice this when:
 - The client fails to send a keepalive packet for as long as specified in `mqtt.Client()`
 - The tcp-connection is properly closed (without closing the mqtt-connection before)
- The broker tries to send data to the client and fails to do so, because the tcp-connection is not longer open.
This means if you specified 120 as keepalive timer, just turn off the client device and the broker does not send any data to the client, the last will message will be published 120s after turning off the device.
#### Syntax
`mqtt:lwt(topic, message[, qos[, retain]])`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment