-
Notifications
You must be signed in to change notification settings - Fork 2.6k
added the reconnect timeout #2026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -1121,6 +1125,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) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| UI.firstReconnectTime = Date.now(); | ||
| } | ||
| const elapsedTime = Date.now() - UI.firstReconnectTime; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems you're not using this variable. |
||
|
|
||
| // Check if we've exceeded the max reconnect time | ||
|
samhed marked this conversation as resolved.
Outdated
|
||
| 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 | ||
|
samhed marked this conversation as resolved.
Outdated
|
||
| UI.updateVisualState('disconnected'); | ||
| return; | ||
| } | ||
|
|
||
| // if reconnect has been disabled in the meantime, do nothing. | ||
| if (UI.inhibitReconnect) { | ||
|
|
@@ -1154,6 +1174,8 @@ const UI = { | |
| } | ||
| UI.showStatus(msg); | ||
| UI.updateVisualState('connected'); | ||
| // Here we can reset the retry count | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. misleading comment |
||
| UI.resetFirstReconnection(); | ||
|
|
||
| UI.updateBeforeUnload(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| {} | ||
| { | ||
| "reconnect_max_time": 600000 | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea is that this should be empty. You will still get the same behavior since you added a default when calling defaults.json could be used by integrators of the noVNC app to provide other defaults. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space before {