diff --git a/lib/proxmox.js b/lib/proxmox.js index 172ce5d..26fa27d 100644 --- a/lib/proxmox.js +++ b/lib/proxmox.js @@ -27,24 +27,16 @@ class ProxmoxUtils { this.sharedMap = {}; this.stopped = false; - - this.communicationErrorCounter = 0; } setNextUrlMain(id) { - if (typeof id === 'number') { - this.currentIpId = id - 1; - } this.currentIpId++; - if (this.currentIpId === this.ipList.length) { + + if (this.currentIpId >= this.ipList.length) { this.currentIpId = 0; } - // if (this.ipList[this.currentIpId]) { - // this.currentIpId = 0; - // } - this.URL = `https://${this.ipList[this.currentIpId]}:${this.port}/api2/json`; return this.URL; } @@ -287,7 +279,6 @@ class ProxmoxUtils { }) .then((response) => { this.adapter.log.debug(`received ${response.status} response from ${pathU} with content: ${JSON.stringify(response.data)}`); - this.communicationErrorCounter = 0; if (response.status === 500 || response.status === 595 || response.status === 599) { reject(response.status + ' - ' + response.data); @@ -310,13 +301,8 @@ class ProxmoxUtils { this.adapter.log.warn(`${additional} -- Use Next Proxmox Host because of communication failure ${this.URL}${url}`); - this.communicationErrorCounter++; - // We experienced error the same as we have servers available, so no chance to retry another server + // select next server and try again this.setNextUrlMain(); - if (this.communicationErrorCounter >= this.ipList.length) { - // this.adapter.log.error(`Error received response from ${error.config.url}`); - this.setNextUrlMain(0); - } this.ticket(async () => { // Retry with new ticket