mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add err handler on tcpout/listener. Fixes #50
This commit is contained in:
parent
6fb8506722
commit
488a039781
@ -71,15 +71,13 @@ function TcpOut(n) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this._close = function() {
|
||||
node.on("close", function() {
|
||||
this.closing = true;
|
||||
client.end();
|
||||
clearTimeout(reconnectTimeout);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
else {
|
||||
} else {
|
||||
var connectedSockets = [];
|
||||
var server = net.createServer(function (socket) {
|
||||
var remoteDetails = socket.remoteAddress+":"+socket.remotePort;
|
||||
@ -89,6 +87,11 @@ function TcpOut(n) {
|
||||
node.log("connection closed from "+remoteDetails);
|
||||
connectedSockets.splice(connectedSockets.indexOf(socket),1);
|
||||
});
|
||||
socket.on('error',function() {
|
||||
node.log("socket error from "+remoteDetails);
|
||||
connectedSockets.splice(connectedSockets.indexOf(socket),1);
|
||||
});
|
||||
|
||||
});
|
||||
node.on("input", function(msg) {
|
||||
if (msg.payload != null) {
|
||||
@ -109,16 +112,12 @@ function TcpOut(n) {
|
||||
server.listen(node.port);
|
||||
node.log('listening on port '+node.port);
|
||||
|
||||
this._close = function() {
|
||||
node.on('close', function() {
|
||||
server.close();
|
||||
node.log('stopped listening on port '+node.port);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
RED.nodes.registerType("tcp out",TcpOut);
|
||||
|
||||
TcpOut.prototype.close = function() {
|
||||
this._close();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user