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?

gefragt vor einem Jahr995 Aufrufe
2 Antworten
1
Akzeptierte Antwort

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
EXPERTE
Greg_B
beantwortet vor einem Jahr
profile pictureAWS
EXPERTE
überprüft vor einem Jahr
0

I will give that a try. Thanks

beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen