diff --git a/packages/node_modules/@node-red/nodes/core/network/31-tcpin.js b/packages/node_modules/@node-red/nodes/core/network/31-tcpin.js index d95d03b10..7cf34f4f8 100644 --- a/packages/node_modules/@node-red/nodes/core/network/31-tcpin.js +++ b/packages/node_modules/@node-red/nodes/core/network/31-tcpin.js @@ -547,10 +547,16 @@ module.exports = function(RED) { this.on("input", function(msg, nodeSend, nodeDone) { var i = 0; - if ((!Buffer.isBuffer(msg.payload)) && (typeof msg.payload !== "string")) { + if (msg.payload !== undefined && (!Buffer.isBuffer(msg.payload)) && (typeof msg.payload !== "string")) { msg.payload = msg.payload.toString(); } + if (node.out === "sit" && msg?.reset === true && node?.last_id && clients[node.last_id]) { + node.status({}); + clients[node.last_id].client.destroy(); + delete clients[node.last_id]; + } + var host = node.server || msg.host; var port = node.port || msg.port; @@ -627,7 +633,9 @@ module.exports = function(RED) { clients[connection_id].connecting = false; let event; while (event = dequeue(clients[connection_id].msgQueue)) { - clients[connection_id].client.write(event.msg.payload); + if (event.msg.payload !== undefined) { + clients[connection_id].client.write(event.msg.payload); + } event.nodeDone(); } if (node.out === "time" && node.splitc < 0) {