mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
3d5ed840dc
commit
a47ad4842a
@ -397,8 +397,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
if (!node.connected) {
|
||||
client = net.Socket();
|
||||
if (socketTimeout) { client.setTimeout(socketTimeout); }
|
||||
//node.status({});
|
||||
if (socketTimeout !== null) { client.setTimeout(socketTimeout); }
|
||||
var host = node.server || msg.host;
|
||||
var port = node.port || msg.port;
|
||||
var m;
|
||||
@ -471,24 +470,31 @@ module.exports = function(RED) {
|
||||
});
|
||||
|
||||
client.on('end', function() {
|
||||
//console.log("END");
|
||||
node.connected = false;
|
||||
node.status({});
|
||||
node.status({fill:"grey",shape:"ring",text:"common.status.disconnected"});
|
||||
node.send({"payload":m});
|
||||
client = null;
|
||||
});
|
||||
|
||||
client.on('close', function() {
|
||||
node.status({});
|
||||
//console.log("CLOSE");
|
||||
node.connected = false;
|
||||
if (node.done) { node.done(); }
|
||||
});
|
||||
|
||||
client.on('error', function() {
|
||||
node.error(RED._("tcpin.errors.connect-fail"),msg);
|
||||
//console.log("ERROR");
|
||||
node.connected = false;
|
||||
node.status({fill:"red",shape:"ring",text:"common.status.error"});
|
||||
node.error(RED._("tcpin.errors.connect-fail"),msg);
|
||||
if (client) { client.end(); }
|
||||
});
|
||||
|
||||
client.on('timeout',function() {
|
||||
//console.log("TIMEOUT");
|
||||
node.connected = false;
|
||||
node.status({fill:"grey",shape:"dot"});
|
||||
node.warn(RED._("tcpin.errors.connect-timeout"));
|
||||
if (client) {
|
||||
client.end();
|
||||
@ -511,6 +517,7 @@ module.exports = function(RED) {
|
||||
buf = null;
|
||||
client.destroy();
|
||||
}
|
||||
node.status({});
|
||||
if (!node.connected) { done(); }
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user