diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index c0c90a035..71498d7e9 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -59,17 +59,18 @@ module.exports = function(RED) { data = data.toString(node.datatype); } if (node.stream) { - if ((node.datatype) === "utf8" && node.newline != "") { + var msg; + if ((node.datatype) === "utf8" && node.newline !== "") { buffer = buffer+data; var parts = buffer.split(node.newline); for (var i = 0;i= node.serialConfig.count) { node.send({"payload": buf}); - client.end(); + if (client) { client.end(); } i = 0; } } @@ -449,7 +456,7 @@ module.exports = function(RED) { var m = new Buffer(i); buf.copy(m,0,0,i); node.send({"payload": m}); - client.end(); + if (client) { client.end(); } m = null; i = 0; }