Keepalive su nodo tcp

This commit is contained in:
Pietro committed 2020-04-16 19:00:35 +02:00
1 parent 2ea5fe3063
commit 0f8107d137
2 files changed
+13 -6

No files matched your search

+3 -2
View File
@@ -55,6 +55,7 @@ module.exports = function(RED) {
this.datatype = n.datatype||'buffer'; /* buffer,utf8,base64 */
this.newline = (n.newline||"").replace("\\n","\n").replace("\\r","\r");
this.base64 = n.base64;
this.keepalive = parseInt(n.keepalive) || 120000;
this.server = (typeof n.server == 'boolean')?n.server:(n.server == "server");
this.closing = false;
this.connected = false;
@@ -76,7 +77,7 @@ module.exports = function(RED) {
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
client.setKeepAlive(true,120000);
client.setKeepAlive(true, this.keepalive);
connectionPool[id] = client;
client.on('data', function (data) {
@@ -151,7 +152,7 @@ module.exports = function(RED) {
}
else {
var server = net.createServer(function (socket) {
socket.setKeepAlive(true,120000);
socket.setKeepAlive(true, this.keepalive);
if (socketTimeout !== null) { socket.setTimeout(socketTimeout); }
var id = (1+Math.random()*4294967295).toString(16);
var fromi;