Skip to content

Commit

Permalink
fix(mqtt binding Atos-Research-and-Innovation#65): correct handling o…
Browse files Browse the repository at this point in the history
…f reconnections (Atos-Research-and-Innovation#67)
  • Loading branch information
dcalvoalonso authored May 8, 2019
1 parent 86459b9 commit 0fa3165
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/bindings/mqttClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class MqttClient {
var options = {};
options.username = this.username;
options.password = this.password;
var connected = false;

winston.info('Connecting to MQTT server %s with options:%s', host, JSON.stringify(options));
this.mqttClient = mqtt.connect(
Expand All @@ -70,7 +71,10 @@ class MqttClient {
this.mqttClient.on('message', this.listener);
this.mqttClient.on('connect', function(object, binding) {
winston.info('Connected to MQTT server');
return callback();
if (!connected) {
connected = true;
return callback();
}
});
}

Expand Down

0 comments on commit 0fa3165

Please sign in to comment.