From efd1aa38ccb8b2efef8cabd85dc3f9e93b8853c7 Mon Sep 17 00:00:00 2001 From: murciano Date: Wed, 4 Jul 2018 16:31:02 +0200 Subject: [PATCH] On Reconnect try all uris --- src/paho-mqtt.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/paho-mqtt.js b/src/paho-mqtt.js index b63170b..7e8950f 100644 --- a/src/paho-mqtt.js +++ b/src/paho-mqtt.js @@ -1528,8 +1528,13 @@ var PahoMQTT = (function (global) { if (this._reconnectInterval < 128) this._reconnectInterval = this._reconnectInterval * 2; if (this.connectOptions.uris) { - this.hostIndex = 0; - this._doConnect(this.connectOptions.uris[0]); + if (this.hostIndex < this.connectOptions.uris.length-1) { + // Try the next host. + this.hostIndex++; + }else{ + this.hostIndex = 0; + } + this._doConnect(this.connectOptions.uris[this.hostIndex]); } else { this._doConnect(this.uri); }