Currently, the simulator may meet connection failure randomly. It will cause the device failed to send and recevie any message. IoT Hub team suggested to re-create the DeviceClient object as a workaround. But it looks not enough, since sometime the it may take quite long time the reconnect to IoTHub even with the new created DeviceClient.
In this code change, we are going to improve the fault tolerance from angles below:
1. Upgrade the Device Client SDK to latest version
2. Add simulator scope check. If 50% devices was found in status "down", the whole simulator process will restart. It will happen only if the simulator was running as a WebJob in cloud environment.
3. [BugFix] Use “finally" statement to ensure the transport object was released
4. Add more trace log
By this code change, we will switch back to the C# device SDK. It will unblock the traditional command, and decrease the memory cost, especially when lots of devices were simulated.
IoT Hub DM feature was GA yesterday. And the NuGet package of the service SDK was updated on last Thursday. We are going to upgrade the package in our project to official version.
There is one minor change in interface: the returned value type of C2D method was changed from string to int.