mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add timeout to httprequest node
and override 2 min default in settings.js. to Close #801
This commit is contained in:
parent
2361607aa3
commit
2ba146b9ff
@ -28,6 +28,8 @@ module.exports = function(RED) {
|
|||||||
var isTemplatedUrl = (nodeUrl||"").indexOf("{{") != -1;
|
var isTemplatedUrl = (nodeUrl||"").indexOf("{{") != -1;
|
||||||
var nodeMethod = n.method || "GET";
|
var nodeMethod = n.method || "GET";
|
||||||
this.ret = n.ret || "txt";
|
this.ret = n.ret || "txt";
|
||||||
|
if (RED.settings.httpRequestTimeout) { this.reqTimeout = parseInt(RED.settings.httpRequestTimeout) || 120000; }
|
||||||
|
else { this.reqTimeout = 120000; }
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
var prox, noprox;
|
var prox, noprox;
|
||||||
@ -162,6 +164,13 @@ module.exports = function(RED) {
|
|||||||
node.status({});
|
node.status({});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
req.setTimeout(node.reqTimeout, function() {
|
||||||
|
node.error(RED._("common.notification.errors.no-response"),msg);
|
||||||
|
setTimeout(function() {
|
||||||
|
node.status({fill:"red",shape:"ring",text:"common.notification.errors.no-response"});
|
||||||
|
},10);
|
||||||
|
req.abort();
|
||||||
|
});
|
||||||
req.on('error',function(err) {
|
req.on('error',function(err) {
|
||||||
msg.payload = err.toString() + " : " + url;
|
msg.payload = err.toString() + " : " + url;
|
||||||
msg.statusCode = err.code;
|
msg.statusCode = err.code;
|
||||||
|
@ -40,6 +40,10 @@ module.exports = {
|
|||||||
// defaults to no timeout
|
// defaults to no timeout
|
||||||
//socketTimeout: 120000,
|
//socketTimeout: 120000,
|
||||||
|
|
||||||
|
// Timeout in milliseconds for HTTP request connections
|
||||||
|
// defaults to 120 seconds
|
||||||
|
//httpRequestTimeout: 120000,
|
||||||
|
|
||||||
// The maximum length, in characters, of any message sent to the debug sidebar tab
|
// The maximum length, in characters, of any message sent to the debug sidebar tab
|
||||||
debugMaxLength: 1000,
|
debugMaxLength: 1000,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user