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:
parent
3255ae4187
commit
38d309dcf3
@ -59,7 +59,7 @@
|
|||||||
outputs:1,
|
outputs:1,
|
||||||
icon: "bridge-dash.png",
|
icon: "bridge-dash.png",
|
||||||
label: function() {
|
label: function() {
|
||||||
return this.name||this.topic||(this.transport+":"+this.port);
|
return this.name||this.topic||("socket "+this.transport+":"+this.port);
|
||||||
},
|
},
|
||||||
labelStyle: function() {
|
labelStyle: function() {
|
||||||
return this.name?"node_label_italic":"";
|
return this.name?"node_label_italic":"";
|
||||||
|
@ -55,8 +55,13 @@ function SocketIn(n) {
|
|||||||
node.send(msg);
|
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);
|
server.listen(node.port);
|
||||||
node.log('tcp listener on port :'+node.port+'/');
|
node.log('tcp listener on port :'+node.port);
|
||||||
|
|
||||||
this._close = function() {
|
this._close = function() {
|
||||||
server.close();
|
server.close();
|
||||||
@ -130,5 +135,3 @@ RED.nodes.registerType("socket in",SocketIn);
|
|||||||
SocketIn.prototype.close = function() {
|
SocketIn.prototype.close = function() {
|
||||||
this._close();
|
this._close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
icon: "bridge-dash.png",
|
icon: "bridge-dash.png",
|
||||||
align: "right",
|
align: "right",
|
||||||
label: function() {
|
label: function() {
|
||||||
return this.name||this.topic||(this.transport+":"+this.port);
|
return this.name||this.topic||("socket "+this.transport+":"+this.port);
|
||||||
},
|
},
|
||||||
labelStyle: function() {
|
labelStyle: function() {
|
||||||
return (this.name||!this.topic)?"node_label_italic":"";
|
return (this.name||!this.topic)?"node_label_italic":"";
|
||||||
|
@ -40,7 +40,8 @@ function SocketOut(n) {
|
|||||||
node.error('tcp : '+err);
|
node.error('tcp : '+err);
|
||||||
});
|
});
|
||||||
client.connect(this.port, this.host, function() {
|
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") {
|
if (this.trans == "udp") {
|
||||||
|
Loading…
Reference in New Issue
Block a user