From 61cb1af0aa7b3394902ab09887b442f1091be29f Mon Sep 17 00:00:00 2001 From: Ankit kumar yadav Date: Wed, 19 Nov 2025 10:32:25 +0530 Subject: [PATCH 1/5] added the reconnect timeout --- app/ui.js | 23 ++++++++++++++++++++++- defaults.json | 4 +++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/app/ui.js b/app/ui.js index 51e57bd3b..12bc94721 100644 --- a/app/ui.js +++ b/app/ui.js @@ -45,6 +45,7 @@ const UI = { inhibitReconnect: true, reconnectCallback: null, reconnectPassword: null, + firstReconnectTime: 0, async start(options={}) { UI.customSettings = options.settings || {}; @@ -961,6 +962,9 @@ const UI = { UI.closePowerPanel(); } }, + resetFirstReconnection(){ + UI.firstReconnectTime = 0; + }, /* ------^------- * /POWER @@ -1120,6 +1124,22 @@ const UI = { reconnect() { 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 (UI.inhibitReconnect) { @@ -1153,7 +1173,8 @@ const UI = { } UI.showStatus(msg); UI.updateVisualState('connected'); - + // Here we can reset the retry count + UI.resetFirstReconnection(); // Do this last because it can only be used on rendered elements UI.rfb.focus(); }, diff --git a/defaults.json b/defaults.json index 0967ef424..de2624428 100644 --- a/defaults.json +++ b/defaults.json @@ -1 +1,3 @@ -{} +{ + "reconnect_max_time": 600000 +} From 5c7b2c3fae51529ceab2b1dfd91004db9c2320ef Mon Sep 17 00:00:00 2001 From: Ankit kumar yadav Date: Fri, 27 Mar 2026 11:09:40 +0530 Subject: [PATCH 2/5] fix the indentation and notification timeout --- app/ui.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/ui.js b/app/ui.js index c1815fa3f..6bf8618e6 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1133,11 +1133,12 @@ const UI = { } const elapsedTime = Date.now() - UI.firstReconnectTime; - // Check if we've exceeded the max reconnect time + // 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 + // Showing this notification for long time, unless user will close this manually or reLaunch the VNC console + UI.showStatus(_("Maximum reconnect attempts reached. Failed to connect to the server."), 'error', Infinity); UI.updateVisualState('disconnected'); return; } From db7c5beea5ed33032d893fd2dfa1229cccf0e23d Mon Sep 17 00:00:00 2001 From: Ankit kumar yadav Date: Sun, 29 Mar 2026 23:56:02 +0530 Subject: [PATCH 3/5] fix the error --- app/ui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/ui.js b/app/ui.js index 6bf8618e6..5b9345884 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1125,7 +1125,7 @@ const UI = { reconnect() { UI.reconnectCallback = null; - const maxTime = UI.getSetting('reconnect_max_time') ?? 600000; // 20s - 20 * 1000 ms + const maxTime = UI.getSetting('reconnect_max_time') ?? 600000; // default to 10 minutes => 10 * 60 * 1000 ms // Initialize first reconnect time if it's the first attempt if (UI.firstReconnectTime === null) { @@ -1137,8 +1137,8 @@ const UI = { if ((Date.now() - UI.firstReconnectTime) >= maxTime) { // hiding the previous status message UI.hideStatus(); - // Showing this notification for long time, unless user will close this manually or reLaunch the VNC console - UI.showStatus(_("Maximum reconnect attempts reached. Failed to connect to the server."), 'error', Infinity); + // Showing this message for long time, because if the connection is unstable and user is not around to see the message when the connection is lost, they will be able to see it when they will come back. (Showing for 3 hours) + UI.showStatus(_("Maximum reconnect attempts reached. Failed to connect to the server."), 'error', 180*60*1000); UI.updateVisualState('disconnected'); return; } From 2449f268f270e4f392c586998c7872b5a529a83b Mon Sep 17 00:00:00 2001 From: Ankit kumar yadav Date: Sun, 3 May 2026 22:53:33 +0530 Subject: [PATCH 4/5] Addressed the review comments --- app/ui.js | 15 +++++++-------- defaults.json | 3 --- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/ui.js b/app/ui.js index 5b9345884..b6dfc8d25 100644 --- a/app/ui.js +++ b/app/ui.js @@ -45,7 +45,7 @@ const UI = { inhibitReconnect: true, reconnectCallback: null, reconnectPassword: null, - firstReconnectTime: 0, + firstReconnectTime: null, async start(options={}) { UI.customSettings = options.settings || {}; @@ -962,8 +962,8 @@ const UI = { UI.closePowerPanel(); } }, - resetFirstReconnection(){ - UI.firstReconnectTime = 0; + resetFirstReconnection() { + UI.firstReconnectTime = null; }, /* ------^------- @@ -1125,20 +1125,20 @@ const UI = { reconnect() { UI.reconnectCallback = null; - const maxTime = UI.getSetting('reconnect_max_time') ?? 600000; // default to 10 minutes => 10 * 60 * 1000 ms + const MAX_RECONNECT_TIME_SECONDS = 10 * 60; // 10 * 60s + const MAX_TIME_IN_MS = MAX_RECONNECT_TIME_SECONDS * 1000; // 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) { + if ((Date.now() - UI.firstReconnectTime) >= MAX_TIME_IN_MS) { // hiding the previous status message UI.hideStatus(); // Showing this message for long time, because if the connection is unstable and user is not around to see the message when the connection is lost, they will be able to see it when they will come back. (Showing for 3 hours) - UI.showStatus(_("Maximum reconnect attempts reached. Failed to connect to the server."), 'error', 180*60*1000); + UI.showStatus(_("Maximum reconnect attempts reached. Failed to connect to the server."), 'error', 180 * 60 * 1000); UI.updateVisualState('disconnected'); return; } @@ -1175,7 +1175,6 @@ const UI = { } UI.showStatus(msg); UI.updateVisualState('connected'); - // Here we can reset the retry count UI.resetFirstReconnection(); UI.updateBeforeUnload(); diff --git a/defaults.json b/defaults.json index de2624428..e69de29bb 100644 --- a/defaults.json +++ b/defaults.json @@ -1,3 +0,0 @@ -{ - "reconnect_max_time": 600000 -} From e47431b215756783d30fd2416cb3cc9373cbf20e Mon Sep 17 00:00:00 2001 From: Ankit kumar yadav Date: Sun, 3 May 2026 22:55:01 +0530 Subject: [PATCH 5/5] revert the default.json changes --- defaults.json | 1 + 1 file changed, 1 insertion(+) diff --git a/defaults.json b/defaults.json index e69de29bb..9e26dfeeb 100644 --- a/defaults.json +++ b/defaults.json @@ -0,0 +1 @@ +{} \ No newline at end of file