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?

질문됨 일 년 전1027회 조회
2개 답변
1
수락된 답변

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
전문가
Greg_B
답변함 일 년 전
profile pictureAWS
전문가
검토됨 일 년 전
0

I will give that a try. Thanks

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠