Azure / azure-iot-sdk-node

A Node.js SDK for connecting devices to Microsoft Azure IoT services
https://docs.microsoft.com/en-us/azure/iot-hub/
Other
261 stars 226 forks source link

when azure iot device is disabled sometimes report properties twin to cloud will success #1193

Open AiHaibara opened 1 year ago

AiHaibara commented 1 year ago

Context

Description of the issue

when i using api to disable a azure iot device, the azure portal show Enable connection to IoT Hub is disable, it can still report properties twin to cloud using amqpws and I want to retry reconnect every 30s, if the device is enabled. but before I enabled it, it will always trigger both the connected and disconnected event and sometimes report properties twin to cloud will success even after 5 minutes or restart program. does the reported success is designed or issue? if that how can i distinguish is disabled or not?

Usage

Enable connection to IoT Hub is disable this.client?._transport.updateTwinReportedProperties every 30s

Result

the twin is success reported

AiHaibara commented 1 year ago

I got a work around now, each time after client open and before report, try to send a event message for any test connect, then report if disable it will not report success when every 30s.

vishnureddy17 commented 1 year ago

when i using api to disable a azure iot device, the azure portal show Enable connection to IoT Hub is disable, it can still report properties twin to cloud using amqpws

Which of the two is happening?

  1. you try to set a reported property, SDK indicates success, and the reported property IS reflected in the device twin on the service
  2. you try to set a reported property, SDK indicates success, and the reported property IS NOT reflected on the device twin on the service (silent failure on the SDK)

Or is it neither?

AiHaibara commented 1 year ago

when i using api to disable a azure iot device, the azure portal show Enable connection to IoT Hub is disable, it can still report properties twin to cloud using amqpws

Which of the two is happening?

  1. you try to set a reported property, SDK indicates success, and the reported property IS reflected in the device twin on the service
  2. you try to set a reported property, SDK indicates success, and the reported property IS NOT reflected on the device twin on the service (silent failure on the SDK)

Or is it neither?

I tried this again.

  1. the reported property is reflected in the device twin on the service can be seen in azure portal. this maybe not each time will report success, many times retry or recreate the client sometimes will succeed.

    "status": "disabled", "statusUpdateTime": "2023-06-28T15:58:49.3568541Z",

    from $metadata "lastcommunicationLocal": { "$lastUpdated": "2023-06-28T16:08:29.5170912Z" }, we can see the "$lastUpdated": "2023-06-28T16:08:29.5170912Z" is later than statusUpdateTime": "2023-06-28T15:58:49.3568541Z"