Skip to content

Commit

Permalink
Added ability to use SSL for MQTT connections on port 443 (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko298 committed Jun 13, 2023
1 parent f84679f commit 0c69d8b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/scripts/services/mqttService.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ function mqttClient($window, $timeout, $q, topicMatches, mqttConnectTimeout,
connectOptions.userName = user;
connectOptions.password = password;
}

if(parseInt(port) === 443 || location.protocol === 'https:') {
connectOptions.useSSL = true
}

id = clientid;

Expand Down Expand Up @@ -169,7 +173,11 @@ function mqttClient($window, $timeout, $q, topicMatches, mqttConnectTimeout,
get: () => MAX_QUEUED_MESSAGES - client.inFlightMessages.length,
});

client.connect(angular.copy(connectOptions));
try {
client.connect(angular.copy(connectOptions));
} catch (e) {
console.error(e);
}
};

//...........................................................................
Expand Down

0 comments on commit 0c69d8b

Please sign in to comment.