From 94ee465682e90adb3f0b0edac99b4dc74d87cdc2 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 2 Feb 2017 09:57:01 +0000 Subject: [PATCH] clone message before send in stay connected mode to Fix #1137 --- nodes/core/io/31-tcpin.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 709552f28..4a9650802 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -444,7 +444,7 @@ module.exports = function(RED) { //node.log(RED._("tcpin.errors.client-connected")); node.status({fill:"green",shape:"dot",text:"common.status.connected"}); if (clients[connection_id] && clients[connection_id].client) { - clients[connection_id].connected = true; + clients[connection_id].connected = true; clients[connection_id].client.write(clients[connection_id].msg.payload); } }); @@ -454,10 +454,10 @@ module.exports = function(RED) { } clients[connection_id].client.on('data', function(data) { - if (node.out == "sit") { // if we are staying connected just send the buffer + if (node.out === "sit") { // if we are staying connected just send the buffer if (clients[connection_id]) { clients[connection_id].msg.payload = data; - node.send(clients[connection_id].msg); + node.send(RED.util.cloneMessage(clients[connection_id].msg)); } } else if (node.splitc === 0) { @@ -533,7 +533,7 @@ module.exports = function(RED) { //console.log("END"); node.status({fill:"grey",shape:"ring",text:"common.status.disconnected"}); if (clients[connection_id] && clients[connection_id].client) { - clients[connection_id].connected = false; + clients[connection_id].connected = false; clients[connection_id].client = null; } }); @@ -541,7 +541,7 @@ module.exports = function(RED) { clients[connection_id].client.on('close', function() { //console.log("CLOSE"); if (clients[connection_id]) { - clients[connection_id].connected = false; + clients[connection_id].connected = false; } var anyConnected = false;