From 48958f392fee24b2952e26b3fc08d46755755847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20L=C3=A9caud=C3=A9?= Date: Tue, 9 May 2017 17:09:21 -0400 Subject: [PATCH] TCP In: Fix error in timout callback (#1249) Thanks @natcl --- nodes/core/io/31-tcpin.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 8fa30095c..58f742521 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -574,14 +574,16 @@ module.exports = function(RED) { clients[connection_id].client.on('timeout',function() { //console.log("TIMEOUT"); - clients[connection_id].connected = false; - node.status({fill:"grey",shape:"dot",text:"tcpin.errors.connect-timeout"}); - //node.warn(RED._("tcpin.errors.connect-timeout")); - if (clients[connection_id] && clients[connection_id].client) { - clients[connection_id].client.connect(port, host, function() { - clients[connection_id].connected = true; - node.status({fill:"green",shape:"dot",text:"common.status.connected"}); - }); + if (clients[connection_id]) { + clients[connection_id].connected = false; + node.status({fill:"grey",shape:"dot",text:"tcpin.errors.connect-timeout"}); + //node.warn(RED._("tcpin.errors.connect-timeout")); + if (clients[connection_id].client) { + clients[connection_id].client.connect(port, host, function() { + clients[connection_id].connected = true; + node.status({fill:"green",shape:"dot",text:"common.status.connected"}); + }); + } } }); }