Skip to content

added the reconnect timeout#2026

Open
Ankit8969 wants to merge 6 commits into
novnc:masterfrom
Ankit8969:reconnect_timeout
Open

added the reconnect timeout#2026
Ankit8969 wants to merge 6 commits into
novnc:masterfrom
Ankit8969:reconnect_timeout

Conversation

@Ankit8969
Copy link
Copy Markdown

This update introduces a maximum reconnect timeout for the VNC client. Currently, when the VNC client attempts to reconnect, it may continue retrying indefinitely if the connection keeps failing, which is not ideal.

With this change, we add a new configuration key, reconnect_max_time, in default.json. This setting allows us to define a maximum duration for reconnection attempts. Once the specified time limit is reached, the client will stop trying to reconnect, preventing unnecessary retries and improving overall stability.

@Ankit8969
Copy link
Copy Markdown
Author

@samhed, please check this PR

Copy link
Copy Markdown
Member

@samhed samhed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. I didn't test it yet, but a few comments from briefly checking the code.

Comment thread app/ui.js Outdated
Comment thread app/ui.js Outdated
@samhed samhed added the feature label Mar 24, 2026
@Ankit8969 Ankit8969 requested a review from samhed March 27, 2026 05:41
Copy link
Copy Markdown
Member

@samhed samhed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and unfortunately, this breaks the reconnection functionality. No matter what I set reconnect_max_time to, the first time reconnect() is called, we abort the reconnection attempts. This is because UI.firstReconnectTime is never set.

I get the impression that you're not testing your code?

Comment thread defaults.json Outdated
Comment thread app/ui.js Outdated
Comment thread app/ui.js Outdated
Comment thread app/ui.js Outdated
Comment thread app/ui.js
Comment thread app/ui.js Outdated
@samhed samhed added the ui/full label Apr 28, 2026
Copy link
Copy Markdown
Author

@Ankit8969 Ankit8969 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have resolved the comments. Please review.

@Ankit8969 Ankit8969 requested a review from samhed May 3, 2026 17:26
Copy link
Copy Markdown
Member

@samhed samhed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I tested again, and it's getting closer. However, the state you end up in after reaching the threshold is broken.

Please, test yourself as well, so we don't need these long feedback cycles.

Comment thread app/ui.js
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.updateVisualState('disconnected');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be UI.cancelReconnect() to avoid ending up in a broken state after reaching the maximum reconnect attempts.

Comment thread app/ui.js
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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants