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 227 forks source link

wouldn't removeAllListeners break all callbacks? #876

Closed bmrpatel closed 4 years ago

bmrpatel commented 4 years ago

In the following sample is calling removeAllListeners and then it is not added back wouldn't this break all the call backs for connect() called on the following line.

https://github.com/Azure/azure-iot-sdk-node/blob/85981e9985fb8499197c2eb0914f3588517b1f8d/device/samples/simple_sample_device.js#L22

When I am testing this sample code, I am also seeing that once disconnect is called device not accepting any DM calls or C2D messages? It becomes unresponsive and I have to restart the process. Sometimes it goes into the infinite loop of disconnect and connect. How do I avoid this issue? Do you have any sample which handles the disconnect with DM calls setup? How do I rewire all the DM calls so that after reconnect it is responsive.

Testing Disconnect I am causing disconnect by attaching the debugger, add break point in one of the DM and wait there for more than 4 minutes to cause timeout on connection. After this device gets into unresponsive mode event after it reconnects.

AB#7982563

YoDaMa commented 4 years ago

that does look like a bug. Thanks for pointing it out. We'll fix this in the sample code.

YoDaMa commented 4 years ago

877 addresses this.

az-iot-builder-01 commented 4 years ago

@bmrpatel, @YoDaMa, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey