Keepalive su nodo tcp
parent
2ea5fe3063
commit
0f8107d137
|
|
@ -40,18 +40,22 @@
|
|||
</select>
|
||||
<span data-i18n="tcpin.label.payload"></span>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label><i class="fa fa-clock-o"></i> <span>Keepalive</span></label>
|
||||
<input type="text" id="node-input-keepalive" style="text-align:end; width:200px !important">
|
||||
</div>
|
||||
|
||||
<div id="node-row-newline" class="form-row hidden" style="padding-left:110px;">
|
||||
<span data-i18n="tcpin.label.delimited"></span> <input type="text" id="node-input-newline" style="width:110px;">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-topic"><i class="fa fa-tasks"></i> <span data-i18n="common.label.topic"></span></label>
|
||||
<input type="text" id="node-input-topic" data-i18n="[placeholder]common.label.topic">
|
||||
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
|
||||
<input type="text" id="node-input-topic" placeholder="topic">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span>Name</span></label>
|
||||
<input type="text" id="node-input-name" placeholder="name">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
@ -67,6 +71,7 @@
|
|||
datamode: { value: "stream" },
|
||||
datatype: { value: "buffer" },
|
||||
newline: { value: "" },
|
||||
keepalive: { value: "120000" },
|
||||
topic: { value: "" },
|
||||
base64: {/*deprecated*/ value: false, required: true }
|
||||
},
|
||||
|
|
@ -103,6 +108,7 @@
|
|||
$("#node-input-server").change(updateOptions);
|
||||
$("#node-input-datatype").change(updateOptions);
|
||||
$("#node-input-datamode").change(updateOptions);
|
||||
$("#node-input-keepalive").spinner({ min: 1 });
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue