I am not exactly starting out with device twin and azure but closer to newbie than expert. I cannot figure out how to correctly manage connection problems with the device twins in azure.
I have a long running node application that opens a client. I find that after days or weeks it may start failing to communicate with the backed device twin. I am not sure how to manage this or more specifically, trap the problem and reconnect.
This is the code:
client.getTwin(function(err, twin) {
if (err) {
console.error('could not get twin');
} else {
console.log('retrieved device twin');
twin.on('properties.desired', function(desiredChange) {
console.log('Do something');
}
}
}
Is there a twin.error method?
Part of the problem is that I cannot seem understand/find the correct documentation on these methods.