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

Fix keepalive handling in MQTT client

Fixes #124
This commit is contained in:
Nick O'Leary 2013-12-29 20:16:27 +00:00
parent 0046164689
commit 1c010c568d

View File

@ -79,7 +79,7 @@ MQTTClient.prototype.connect = function(options) {
var now = (new Date()).getTime(); var now = (new Date()).getTime();
if (now - self.lastOutbound > self.options.keepalive*500 || now - self.lastInbound > self.options.keepalive*500) { if (now - self.lastOutbound > self.options.keepalive*500 || now - self.lastInbound > self.options.keepalive*500) {
if (self.pingOutstanding) { if (self.pingOutstanding) {
// DO DISCONNECT self.client.disconnect();
} else { } else {
self.lastOutbound = (new Date()).getTime(); self.lastOutbound = (new Date()).getTime();
self.lastInbound = (new Date()).getTime(); self.lastInbound = (new Date()).getTime();
@ -89,7 +89,9 @@ MQTTClient.prototype.connect = function(options) {
} }
},self.options.keepalive*500,self); },self.options.keepalive*500,self);
self.pingOutstanding = false;
self.lastInbound = (new Date()).getTime() self.lastInbound = (new Date()).getTime()
self.lastOutbound = (new Date()).getTime()
self.connected = true; self.connected = true;
self.emit('connect'); self.emit('connect');
} else { } else {