Skip to content

Commit

Permalink
Don't reschedule pings after getting data - causes nodes that just re…
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Aug 13, 2018
1 parent b9d72e5 commit 4880f0d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/MQTT.js
Expand Up @@ -55,6 +55,8 @@ function MQTT(server, options) {
this.password = options.password;
this.client = false;
this.connected = false;
/* if keep_alive is less than the ping interval we need to use
a shorter ping interval, otherwise we'll just time out! */
this.ping_interval =
this.keep_alive < this.C.PING_INTERVAL ? (this.keep_alive - 5) : this.C.PING_INTERVAL;
this.protocol_name = options.protocol_name || "MQTT";
Expand Down Expand Up @@ -228,8 +230,6 @@ MQTT.prototype.connect = function (client) {
client.emit('data', data.substr(pLen));
}

if (type !== TYPE.PINGRESP) pinger();

if (type === TYPE.PUBLISH) {
var parsedData = parsePublish(data[0],pData);
if (parsedData !== undefined) {
Expand Down Expand Up @@ -279,7 +279,7 @@ MQTT.prototype.connect = function (client) {
var returnCode = pData.charCodeAt(3);
if (RETURN_CODES[returnCode] === 'ACCEPTED') {
mqo.connected = true;
pinger();
pinger(); // start pinging
mqo.emit('connected');
mqo.emit('connect');
}
Expand Down

0 comments on commit 4880f0d

Please sign in to comment.