Hi,
I'm trying to do a node like "http request", i used the source of this node as inspiration,
but when i do a request that the remote address takes some time to respond or don't respond at all, my node-red gets stuck.
The "http request" node doesn't do that.
I tried with the library "Got" with the same result.
node.on('input', (msg, send, done) => {
request('http://192.168.200.220:1880/test', function(err, res, body) {
if(err) {
msg.payload = 'Error';
msg.statusCode = 404;
node.send(msg);
done();
} else {
msg.payload = body;
msg.statusCode = 200;
node.send(msg);
done();
}
});
/*(async () => {
try {
const response = await got('http://192.168.200.220:1880/test');
if(response !== undefined) {
msg.payload = response.body;
msg.statusCode = 200;
node.send(msg);
done();
} else {
msg.payload = "Error";
msg.statusCode = 404;
node.send(msg);
done();
}
} catch(error) {
msg.payload = 'Error';
msg.statusCode = 404;
node.send(msg);
done();
}
})();*/
});
I use a disconnected "http in" node to test a non responsive http request.
Thanks.