Catching http request errors

1,622 views
Skip to first unread message

Alexander Pivovarov

unread,
Mar 9, 2016, 3:37:34 PM3/9/16
to Node-RED

Hi, 


I have a simple flow with http request node. If the requested server is not available it generates errors in debug log.

Catch node catches error but there are still uncatched errors "no response from the server".

How can I rid of them?


Thanks






Mark Setrem

unread,
Mar 9, 2016, 6:19:32 PM3/9/16
to Node-RED
What have you tried? It appears they are coming from your function node, so have you tried having an initial part of you function that if that is the message do nothing.


Alexander Pivovarov

unread,
Mar 10, 2016, 1:39:31 AM3/10/16
to Node-RED
I want to get rid of error in debug log. 
I changed the flow and removed all debug outputs.  I also removed all other flows.
Errors are still there (see the picture attached).


Here is the flow: 
[{"id":"d3c31203.2c3cf","type":"inject","z":"454986cf.bab678","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"x":160.5,"y":107,"wires":[["32bab280.cd454e"]]},{"id":"32bab280.cd454e","type":"http request","z":"454986cf.bab678","name":"","method":"GET","ret":"obj","url":"http://192.168.2.63:8000","x":350.5,"y":106,"wires":[[]]},{"id":"1d5a5b25.e2a5a5","type":"catch","z":"454986cf.bab678","name":"","scope":null,"x":332.5,"y":203,"wires":[["cc0eeb9c.33f118"]]},{"id":"cc0eeb9c.33f118","type":"function","z":"454986cf.bab678","name":"do nothing","func":"\nreturn null;","outputs":1,"noerr":0,"x":538.5,"y":202,"wires":[[]]}]



Dave C-J

unread,
Mar 10, 2016, 3:48:33 AM3/10/16
to node...@googlegroups.com
​When I run your short flow above all I get is the status error indicator - nothing in console.log or the debug window
Inline images 1

Dave C-J

unread,
Mar 10, 2016, 3:49:12 AM3/10/16
to node...@googlegroups.com
Which version on node.js and node-red are you running ? what platform ?

Alexander Pivovarov

unread,
Mar 10, 2016, 4:44:22 AM3/10/16
to Node-RED


четверг, 10 марта 2016 г., 11:49:12 UTC+3 пользователь Dave C-J написал:
Which version on node.js and node-red are you running ? what platform ?

I forgot to add - it's necessary to wait 3-5 minutes. The output starts not immediately but after a while.

[info] Node-RED version: v0.13.3
[info] Node.js  version: v4.2.4 
Platfrom: OSX

PS
Node-red outputs this error to console as well:
10 Mar 12:36:48 - [warn] [http request:8e0b1e21.71f4e] JSON parse error
10 Mar 12:36:49 - [warn] [http request:8e0b1e21.71f4e] JSON parse error
10 Mar 12:36:50 - [warn] [http request:8e0b1e21.71f4e] JSON parse error



Dave C-J

unread,
Mar 10, 2016, 4:58:44 AM3/10/16
to node...@googlegroups.com
I've been running since 8:47 and it's now 9:56... still waiting for an error...
You are requesting something from a non-existant server once a second - so at some point I'm not too surprised you get an error. Why would you not want it reported ?

Alexander Pivovarov

unread,
Mar 10, 2016, 6:06:44 AM3/10/16
to Node-RED
Well. I tried to do more tests and indeed sometimes I got these errors and sometimes not.
Right now I don't have any errors and even if I add catch node - I get no errors at all. For example, this flow should generate errors (as I think), but right now - I see nothing in the log. 

[{"id":"2f5a0576.d0a5fa","type":"inject","z":"454986cf.bab678","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"x":172,"y":181,"wires":[["8e0b1e21.71f4e"]]},{"id":"8e0b1e21.71f4e","type":"http request","z":"454986cf.bab678","name":"","method":"GET","ret":"txt","url":"http://121.168.2.37:8000","x":396,"y":190,"wires":[[]]},{"id":"34c19af3.cb3e66","type":"catch","z":"454986cf.bab678","name":"","scope":null,"x":378,"y":287,"wires":[["e654dc9c.19ab2","2cd9b5e7.d3264a"]]},{"id":"e654dc9c.19ab2","type":"function","z":"454986cf.bab678","name":"do nothing","func":"\nreturn null;","outputs":1,"noerr":0,"x":588,"y":282,"wires":[[]]},{"id":"2cd9b5e7.d3264a","type":"debug","z":"454986cf.bab678","name":"","active":true,"console":"false","complete":"false","x":581.5,"y":341,"wires":[]}]

Cant' reproduce steps that results in these errors in the debug log....



четверг, 10 марта 2016 г., 12:58:44 UTC+3 пользователь Dave C-J написал:

Alexander Pivovarov

unread,
Mar 10, 2016, 6:09:11 AM3/10/16
to Node-RED
Actually, what I want is to catch http-errors with catch node and send email alert if the server is not available...

четверг, 10 марта 2016 г., 12:58:44 UTC+3 пользователь Dave C-J написал:

Dave C-J

unread,
Mar 10, 2016, 2:50:33 PM3/10/16
to node...@googlegroups.com
Ah right - the http request node itself should return the error... (rather than the catch)...

it returns an object like - { "topic": "", "payload": "Error: connect ETIMEDOUT 192.168.2.63:8000 : http://192.168.2.63:8000", "_msgid": "f952a791.06ad58", "statusCode": "ETIMEDOUT" } 
The key here is to look for msg.statusCode -  if msg.hasOwnProperty("statusCode") {...
and react accordingly.

Alexander Pivovarov

unread,
Mar 11, 2016, 1:39:05 AM3/11/16
to Node-RED
Ok, thanks. Though the issue is still not resolved as I am continue getting debug messages if the server is down. 
They are also show in node-red log (in terminal):

11 Mar 09:34:04 - [error] [http request:6a98838b.95677c] no response from server

11 Mar 09:34:10 - [error] [http request:e774a8c7.188b58] no response from server

11 Mar 09:34:10 - [error] [http request:c37f16bc.3c80e8] no response from server


Probably it's also a "feature" of OSX, which is development platform. I will check how it behaves on a production platform.
If the problem exists there would try to reproduce it there.

-ap


четверг, 10 марта 2016 г., 22:50:33 UTC+3 пользователь Dave C-J написал:

Dave C-J

unread,
Mar 11, 2016, 4:32:04 AM3/11/16
to node...@googlegroups.com
They are errors so yes they are logged.

Alexander Pivovarov

unread,
Mar 11, 2016, 4:35:00 AM3/11/16
to Node-RED
Hm... Can I get rid of them then? (catch node doesn't work)

11 марта 2016 г., 12:32:04 UTC+3 пользователь Dave C-J написал:

Dave C-J

unread,
Mar 11, 2016, 6:20:49 AM3/11/16
to node...@googlegroups.com
no sorry. 
You could customise it locally by commenting out line 168 of file 21-httprequest.js
Reply all
Reply to author
Forward
0 new messages