Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(mqtt binding #65): correct handling of reconnections #67

Merged
merged 1 commit into from
May 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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