-
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 4 commits
61cb1af
5d7e66b
5c7b2c3
db7c5be
2449f26
e47431b
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,23 @@ const UI = { | |
|
|
||
| reconnect() { | ||
| UI.reconnectCallback = null; | ||
| const maxTime = UI.getSetting('reconnect_max_time') ?? 600000; // default to 10 minutes => 10 * 60 * 1000 ms | ||
|
samhed marked this conversation as resolved.
Outdated
|
||
|
|
||
| // Initialize first reconnect time if it's the first attempt | ||
| if (UI.firstReconnectTime === null) { | ||
|
Ankit8969 marked this conversation as resolved.
|
||
| UI.firstReconnectTime = Date.now(); | ||
| } | ||
| const elapsedTime = Date.now() - UI.firstReconnectTime; | ||
|
samhed marked this conversation as resolved.
Outdated
|
||
|
|
||
| // Check if we've exceeded the max reconnect time | ||
| if ((Date.now() - UI.firstReconnectTime) >= maxTime) { | ||
| // 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) | ||
|
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 looks like the rest of the file avoids long lines like this one. |
||
| UI.showStatus(_("Maximum reconnect attempts reached. Failed to connect to the server."), 'error', 180*60*1000); | ||
| UI.updateVisualState('disconnected'); | ||
|
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. This should be |
||
| return; | ||
| } | ||
|
|
||
| // if reconnect has been disabled in the meantime, do nothing. | ||
| if (UI.inhibitReconnect) { | ||
|
|
@@ -1154,6 +1175,8 @@ const UI = { | |
| } | ||
| UI.showStatus(msg); | ||
| UI.updateVisualState('connected'); | ||
| // Here we can reset the retry count | ||
|
samhed marked this conversation as resolved.
Outdated
|
||
| UI.resetFirstReconnection(); | ||
|
|
||
| UI.updateBeforeUnload(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,3 @@ | ||
| {} | ||
| { | ||
| "reconnect_max_time": 600000 | ||
| } | ||
|
samhed marked this conversation as resolved.
Outdated
|
||
Uh oh!
There was an error while loading. Please reload this page.