Skip to content
Open
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
9 changes: 7 additions & 2 deletions src/paho-mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ function onMessageArrived(message) {
this.connected = false;


this._trace("_doConnect ", wsurl);

if (this.connectOptions.mqttVersion < 4) {
this.socket = new global.WebSocket(wsurl, ["mqttv3.1"]);
Expand Down Expand Up @@ -1542,8 +1543,12 @@ function onMessageArrived(message) {
if (this._reconnectInterval < 128)
this._reconnectInterval = this._reconnectInterval * 2;
if (this.connectOptions.uris) {
this.hostIndex = 0;
this._doConnect(this.connectOptions.uris[0]);
// Loop through all host until we find an working one.
this.hostIndex++;
if (this.hostIndex >= this.connectOptions.uris.length) {
this.hostIndex = 0;
}
this._doConnect(this.connectOptions.uris[this.hostIndex]);
} else {
this._doConnect(this.uri);
}
Expand Down