Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to Fetch connectionState from 1000's of devices - Azure IoTHub

Best way to Fetch connectionState from 1000's of devices. Currently there is not that much devices, but need an efficient solution.

Based on my understanding, currently I can fetch connectionState using

  1. IotHub Queries(select * from devices) or registryManager.GetDevicesAsync(100); -- these methods are not real time when querying for 1000's of devices, or wont be efficient when number of devices increase.
  2. HeartBeat - I don't prefer this as this will overload quota when the number of devices is large which results in sending too many messages.
  3. Operations Monitoring/Diagnostics Monitoring -- First one is good but its getting deprecated by October, 2018 and second one takes about 2 minutes to get message in eventhub(this latency I have tried myself and found out).

Please Suggest some ways and also correct me if I am wrong about any of the above.

like image 754
Renil Joseph Avatar asked Oct 28 '22 14:10

Renil Joseph


1 Answers

ConnectionState field is only suggested to use during development and debugging not in the product solution.

And there is a limitation of retrieving connectionState because the Maximum number of device identities returned in a single call is 1000.

If your IoT solution needs to know if a device is connected, you should implement the heartbeat pattern.

Since considering the overhead of heartbeat that you concerned, you can set a smaller timeout using this API: DeviceClient.OperationTimeoutInMilliseconds.

This pattern achieves the same result as maintaining a device connection state registry using the heartbeat pattern, while being more efficient.

like image 168
Rita Han Avatar answered Nov 01 '22 19:11

Rita Han