Raspberry Pi and Azure IoT Hub are connected via MQTT.
Sometimes the connections are bad and the devices disconnect from each other.
If you get disconnected, restart your browser or "restart the flow" and the connection will be restored.
It is a hassle to do it manually each time.
Is it possible to restart the flow automatically?
In the debug messages, the following error is output.
06/02/2020 9:21:34 node: Azure IoT Hub
msg : string[62]
"Error while trying to send message:Error: client disconnecting"
Is it possible to restart the flow if this message is caught?
Thanks.
Thats what the catch node in your palette is for. It can either catch all errors or just listen to a specific node and will output messages on errors for you to act on:
you can also use the status node which outputs messages if the text status that is below some nodes in the editor changes for the selected node. The mqtt node has a disconnected status that you could act on this way.
If restarting the browser restores the connection then something very odd is going on as the browser only shows the current state, restarting the browser should have no effect on mqtt connections.
Can you describe please exactly the symptom you are seeing that tells you it is disconnected and what changes when you restart the browser, without touching anything else. Restarting the browser should not change anything on the server except UI related stuff.
Unfortunately there does not seem to be a github (or any other) repository linked so I don't know how you can feed the question to the node's authors or submit an issue against it.
If you want to force a restart when that message appears then if you put a Switch node on the output of the azure node you can detect the specific message using the payload Contains test, then use that to trigger a restart.
How did you install node-red on the Pi? It might be worth restarting node red in a terminal using node-red-stop && node-red-start
trigger the error, if you can make it fail, and then copy/paste the complete log output here. That will tell us what versions of all the tools you are using and may give further information about the error.
When pasting the log click the </> button and paste it in there, that will stop the forum interpreting the log as markdown text.