1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

improved error handling (and labelling) for socket node... but not perfect by a long way...

This commit is contained in:
Dave C-J 2013-09-06 21:43:54 +01:00
parent 3255ae4187
commit 38d309dcf3
4 changed files with 10 additions and 6 deletions

View File

@ -59,7 +59,7 @@
outputs:1,
icon: "bridge-dash.png",
label: function() {
return this.name||this.topic||(this.transport+":"+this.port);
return this.name||this.topic||("socket "+this.transport+":"+this.port);
},
labelStyle: function() {
return this.name?"node_label_italic":"";

View File

@ -55,8 +55,13 @@ function SocketIn(n) {
node.send(msg);
});
});
server.on('error', function (e) {
if (e.code == 'EADDRINUSE') {
setTimeout(node.error('TCP port is already in use - please reconfigure socket.'),250);
}
});
server.listen(node.port);
node.log('tcp listener on port :'+node.port+'/');
node.log('tcp listener on port :'+node.port);
this._close = function() {
server.close();
@ -130,5 +135,3 @@ RED.nodes.registerType("socket in",SocketIn);
SocketIn.prototype.close = function() {
this._close();
}

View File

@ -57,7 +57,7 @@
icon: "bridge-dash.png",
align: "right",
label: function() {
return this.name||this.topic||(this.transport+":"+this.port);
return this.name||this.topic||("socket "+this.transport+":"+this.port);
},
labelStyle: function() {
return (this.name||!this.topic)?"node_label_italic":"";

View File

@ -40,7 +40,8 @@ function SocketOut(n) {
node.error('tcp : '+err);
});
client.connect(this.port, this.host, function() {
client.end(msg.payload);
try { client.end(msg.payload); }
catch (e) { node.error(e); }
});
}
if (this.trans == "udp") {