added the reconnect timeout
This commit is contained in:
parent
4cb5aa45ae
commit
61cb1af0aa
23
app/ui.js
23
app/ui.js
|
|
@ -45,6 +45,7 @@ const UI = {
|
||||||
inhibitReconnect: true,
|
inhibitReconnect: true,
|
||||||
reconnectCallback: null,
|
reconnectCallback: null,
|
||||||
reconnectPassword: null,
|
reconnectPassword: null,
|
||||||
|
firstReconnectTime: 0,
|
||||||
|
|
||||||
async start(options={}) {
|
async start(options={}) {
|
||||||
UI.customSettings = options.settings || {};
|
UI.customSettings = options.settings || {};
|
||||||
|
|
@ -961,6 +962,9 @@ const UI = {
|
||||||
UI.closePowerPanel();
|
UI.closePowerPanel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
resetFirstReconnection(){
|
||||||
|
UI.firstReconnectTime = 0;
|
||||||
|
},
|
||||||
|
|
||||||
/* ------^-------
|
/* ------^-------
|
||||||
* /POWER
|
* /POWER
|
||||||
|
|
@ -1120,6 +1124,22 @@ const UI = {
|
||||||
|
|
||||||
reconnect() {
|
reconnect() {
|
||||||
UI.reconnectCallback = null;
|
UI.reconnectCallback = null;
|
||||||
|
const maxTime = UI.getSetting('reconnect_max_time') ?? 600000; // 20s - 20 * 1000 ms
|
||||||
|
|
||||||
|
// Initialize first reconnect time if it's the first attempt
|
||||||
|
if (UI.firstReconnectTime === null) {
|
||||||
|
UI.firstReconnectTime = Date.now();
|
||||||
|
}
|
||||||
|
const elapsedTime = Date.now() - UI.firstReconnectTime;
|
||||||
|
|
||||||
|
// Check if we've exceeded the max reconnect time
|
||||||
|
if ((Date.now() - UI.firstReconnectTime) >= maxTime) {
|
||||||
|
// hiding the previous status message
|
||||||
|
UI.hideStatus();
|
||||||
|
UI.showStatus(_("Maximum reconnect attempts reached. Failed to connect to the server."), 'error', 1000*60*240); // Show for 4 hours
|
||||||
|
UI.updateVisualState('disconnected');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if reconnect has been disabled in the meantime, do nothing.
|
// if reconnect has been disabled in the meantime, do nothing.
|
||||||
if (UI.inhibitReconnect) {
|
if (UI.inhibitReconnect) {
|
||||||
|
|
@ -1153,7 +1173,8 @@ const UI = {
|
||||||
}
|
}
|
||||||
UI.showStatus(msg);
|
UI.showStatus(msg);
|
||||||
UI.updateVisualState('connected');
|
UI.updateVisualState('connected');
|
||||||
|
// Here we can reset the retry count
|
||||||
|
UI.resetFirstReconnection();
|
||||||
// Do this last because it can only be used on rendered elements
|
// Do this last because it can only be used on rendered elements
|
||||||
UI.rfb.focus();
|
UI.rfb.focus();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
{}
|
{
|
||||||
|
"reconnect_max_time": 600000
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue