From 1c010c568dedebacf8d82131bb431fd035ab838a Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Sun, 29 Dec 2013 20:16:27 +0000 Subject: [PATCH] Fix keepalive handling in MQTT client Fixes #124 --- nodes/core/io/lib/mqtt.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodes/core/io/lib/mqtt.js b/nodes/core/io/lib/mqtt.js index 2ff7883ec..1c1e4e498 100644 --- a/nodes/core/io/lib/mqtt.js +++ b/nodes/core/io/lib/mqtt.js @@ -79,7 +79,7 @@ MQTTClient.prototype.connect = function(options) { var now = (new Date()).getTime(); if (now - self.lastOutbound > self.options.keepalive*500 || now - self.lastInbound > self.options.keepalive*500) { if (self.pingOutstanding) { - // DO DISCONNECT + self.client.disconnect(); } else { self.lastOutbound = (new Date()).getTime(); self.lastInbound = (new Date()).getTime(); @@ -89,7 +89,9 @@ MQTTClient.prototype.connect = function(options) { } },self.options.keepalive*500,self); + self.pingOutstanding = false; self.lastInbound = (new Date()).getTime() + self.lastOutbound = (new Date()).getTime() self.connected = true; self.emit('connect'); } else {