IoT disconnected lifecycle event is not generated on device power/network loss

0

I've found that the disconnected lifecycle event ($aws/events/presence/disconnected/clientId) is not generated if the IoT device loses power or network access. It seems the disconnected event is only generated if the mqtt client can send a disconnect. If the device loses power/network that obviously isn't possible.

What's the best approach to handling this?

asked a year ago925 views
2 Answers
1
Accepted Answer

Hi james-ld. It will be generated, but only after the keep-alive timeout expires. This is the MQTT_KEEP_ALIVE_TIMEOUT disconnect reason described here: https://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html#connect-disconnect.

If there is no client-server communication for 1.5x of the client's keep-alive time, the client is disconnected.

The keep-alive timeout can be set from the client side when the MQTT connection is established. For example, with the embedded C SDK: https://github.com/aws/aws-iot-device-sdk-embedded-C/blob/1ef5ffc906fa208752bea1ff02156605a86141c7/demos/mqtt/mqtt_demo_mutual_auth/mqtt_demo_mutual_auth.c#L1131. However, IoT Core will treat any value less than 30 as 30: https://docs.aws.amazon.com/general/latest/gr/iot-core.html#message-broker-limits.

You might also be interested in last will and testament: https://aws.amazon.com/blogs/iot/monitor-aws-iot-connections-in-near-real-time-using-mqtt-lwt/.

profile pictureAWS
EXPERT
Greg_B
answered a year ago
profile pictureAWS
EXPERT
reviewed a year ago
0

I will give that a try. Thanks

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions