> So, when a client connects with clean session set, should/must the Last Will
> and Testament (LWT) information be discarded ?
The clean session flag has no effect on the LWT behaviour.
When a client disconnects abnormally, the Will is published. When a
client disconnects cleanly, the Will is discarded without being
published.
If the Retain flag is set on the Will message, then it will be
retained like any other retained message.
> Consider a case when client C0 had connected with clean session set, LWT
> information provided and Will Retain flag also set. C0 dies abruptly. Then,
> the broker publishes to the Will Topic with Will Retain flag set. Assume
> that, C0 is now reconnecting with the clean session set and the former LWT
> information is not discarded. Now, if C1 connects and subscribers to the
> same Will Topic, then it will get the LWT message even when C0 isn't dead.
The LWT only indicates that the client disconnected abnormally. If it
is being used to maintain a record of whether the client is connected
or not, then the client needs to publish a 'connected' message when it
reconnects. This pattern is described on the wiki:
http://mqtt.org/wiki/doku.php/presence
> Consider a case when client C0 had connected with clean session set and Will
> Retain flag also set. Suppose, C0 issues a DISCONNECT explicitly. At this
> point, the LWT is not published by the broker; nor is the LWT information
> discarded because these are not triggered by DISCONNECT. Assume that, C0 is
> now reconnecting with the clean session set and the Will Topic is not
> discarded. However, in this reconnection, a new set of LWT information is
> provided. Certainly, this LWT information should "over write" the formerly
> maintained LWT information ?
The LWT information is discarded when the client disconnects,
regardless of the clean session flag, so this scenario is invalid.
Regards,
Nick
> --
> To learn more about MQTT please visit
http://mqtt.org
>
> To post to this group, send email to
mq...@googlegroups.com
> To unsubscribe from this group, send email to
>
mqtt+uns...@googlegroups.com
>
> For more options, visit this group at
>
http://groups.google.com/group/mqtt