Node-Red "http request" node stuck in requesting if no connection

Viewed 974

I have a flow with a http request node in it, which makes POST calls to a web service.

Everything works ok, but if the device where Node-Red is running loses connection to Internet (it is connected through LTE), the node keeps stuck in requesting state, instead of returning an error.

node requesting

Is this the normal behaviour? Could I solve it by setting a timeout? How could it be done?

4 Answers

Updating Node-RED to latest version resolved the issue. Now I get an error as I would expect, and Node-RED does not hang.

enter image description here

I have updated from version v0.19.5 to v 1.0.3.

To set timeout in your request, set msg.httpRequestTimeout with the number of miliseconds at the node before your request.

Example:

enter image description here

inside node "Set Timeout"

msg.httpRequestTimeout = 60000;
return msg;

My approach to this would be to first check if the internet is available (example: by pinging google) if it fails, then return an error.

you can set requestTimeout input value for this particular node.

Related