MQTT what is the purpose or usage of Last Will Testament?

后端 未结 3 2077
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 13:48

I\'m surely missing something about how the whole MQTT protocol works, as I can\'t grasp the usage pattern of Last Will Testament messages: what\'s their purpose?
O

3条回答
  •  悲哀的现实
    2021-01-30 14:10

    Just because a device is not publishing does not mean it is not online or there is a network problem.

    Take for example a sensor that monitors a value that only changes very infrequently, good design says that the sensor should only publish the changes to help reduce bandwidth usage as periodically publishing the same value is wasteful. If the value is published as a retained value then any new subscriber will always get the current value without having to wait for the sensor value to change and it publish again.

    In this case the LWT is used to published when the sensor fails (or there is a network problem) so we know of the problem as soon at the client keep alive times out.

提交回复
热议问题