I have the list (text format) of the earthquakes in Italy.
How can I do to test if this address is down? (or up of course)
I send an http request every 60 min and a few days ago the server was down and node (red) was in loop (?)
So the suggestion is to install node-red-node-ping and ping webservices.ms.ingv.it to determine if the host is online. But TBH, its not necessary. Rather, i suspect you have a bug in your flows that doesnt correctly handle a bad response.
You are right, the hostname is pingable ....
I cannot share my flow because it's a part of a flow very complex .....
After the http request node I have this function ....
and in the flow I have a catch node that never reports an error ...
How can I set a specific handling error for http request node ?
Check msg.statusCode in a switch node. If if is 400 or greater then you have an error.
As a guess, you have the catch node doing a retry or something? I think you are making a loop. As a test, connect the catch node to a DEBUG ONLY (nothing else). Also, set the DEBUG to "show complete message"
PS: Please do not send pictures of code - i cannot copy paste and correct easily and pictures are not (easily) searchable!
For example this happens when one of my cam have bad wifi connection
I have a msg.statusCode == "EHOSTUNREACH", string, not number ....
but it's a different case maybe .....(?)
No, I don't have the catch node doing a retry ....
I think to have a loop because after a probelm with http request the cup work increases significantly (4% to 28%) and also the cpu temperature and I'm forced to restart node-red.
that is a different issue though. That is when the host is not on line. your issue was:
so you would have gotten a status number code. (at least i think so)
TBH, I forgot about the status code could be a string and its not great IMO (unreliable)
In short, swap the logic in your function to check that it === 200 or === 201
if (msg.statusCode === 200 || msg.statusCode === 201) {
// all good, send it out of output [1]
} else {
// no, bad response! send it out of output [0]
}