Skip to content

Honour consoleproxy.session.timeout for noVNC sessions (fixes #12810)#13002

Open
dheeraj12347 wants to merge 3 commits intoapache:mainfrom
dheeraj12347:fix-12810-consoleproxy-timeout
Open

Honour consoleproxy.session.timeout for noVNC sessions (fixes #12810)#13002
dheeraj12347 wants to merge 3 commits intoapache:mainfrom
dheeraj12347:fix-12810-consoleproxy-timeout

Conversation

@dheeraj12347
Copy link
Copy Markdown
Contributor

Fixes #12810.

Changes:

  • services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java

    • Add static field sessionTimeoutMillis with a default of 300000 ms (5 minutes).
    • Read the global setting consoleproxy.session.timeout from the configuration and set sessionTimeoutMillis accordingly, with logging and validation.
    • Pass the timeout information to ConsoleProxyGCThread (via the shared ConsoleProxy.sessionTimeoutMillis value).
  • services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyGCThread.java

    • Replace the hard-coded MAX_SESSION_IDLE_SECONDS with DEFAULT_MAX_SESSION_IDLE_SECONDS.
    • Add getMaxSessionIdleSeconds() to derive the idle timeout from ConsoleProxy.sessionTimeoutMillis (falling back to the default when the setting is disabled or invalid).
    • Use getMaxSessionIdleSeconds() when deciding whether to close idle sessions.
  • services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVNCHandler.java

    • Set the Jetty WebSocket Session idle timeout from ConsoleProxy.sessionTimeoutMillis.
    • Improve error logging in onError() to include the exception only when the viewer is available, and add a separate log message for errors before viewer initialization.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the console-proxy server to honor the consoleproxy.session.timeout configuration for noVNC WebSocket sessions and for server-side idle-session cleanup, addressing issue #12810 where noVNC sessions did not time out as expected.

Changes:

  • Introduces a shared ConsoleProxy.sessionTimeoutMillis (default 5 minutes) loaded from consoleproxy.session.timeout.
  • Uses the configured timeout for noVNC WebSocket idle timeouts and for GC-based idle session eviction.
  • Improves noVNC WebSocket error handling/logging to avoid null viewer access.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java Adds and loads sessionTimeoutMillis from configuration; wires GC thread startup.
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyGCThread.java Replaces hardcoded idle timeout with a derived value from sessionTimeoutMillis.
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVNCHandler.java Sets Jetty WebSocket idle timeout from sessionTimeoutMillis; hardens frame/error handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 1.31579% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.01%. Comparing base (3166e64) to head (6eef242).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...main/java/com/cloud/consoleproxy/ConsoleProxy.java 2.04% 48 Missing ⚠️
...m/cloud/consoleproxy/ConsoleProxyNoVNCHandler.java 0.00% 14 Missing ⚠️
...a/com/cloud/consoleproxy/ConsoleProxyGCThread.java 0.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #13002   +/-   ##
=========================================
  Coverage     18.01%   18.01%           
- Complexity    16607    16609    +2     
=========================================
  Files          6029     6029           
  Lines        542160   542170   +10     
  Branches      66451    66462   +11     
=========================================
+ Hits          97682    97687    +5     
- Misses       433461   433466    +5     
  Partials      11017    11017           
Flag Coverage Δ
uitests 3.52% <ø> (ø)
unittests 19.17% <1.31%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DaanHoogland
Copy link
Copy Markdown
Contributor

@dheeraj12347 , can you asses the co-pilot’s comments (and close or apply as applicable)?

@DaanHoogland DaanHoogland added this to the 4.23.0 milestone Apr 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make noVNC console sessions respect the global consoleproxy.session.timeout setting (issue #12810) by wiring the configured timeout into the console-proxy process and applying it to both WebSocket sessions and idle-session cleanup.

Changes:

  • Refactors logging/validation in the noVNC WebSocket handler and console-proxy bootstrap code.
  • Refactors GC thread logging/loop variables and keeps an explicit idle-session constant.
  • (Per PR description) intended: read/apply consoleproxy.session.timeout and use it for noVNC/GC timeouts — but this wiring is not present in the current diffs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java Improves properties handling/logging and resource closing, but does not currently read/apply consoleproxy.session.timeout.
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyGCThread.java Refactors logging/loop code; still uses a hard-coded 180s idle timeout.
services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyNoVNCHandler.java Improves error handling/logging and viewer-null handling; does not currently set WebSocket session idle timeout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +160 to 169
s = conf != null ? conf.getProperty("consoleproxy.readTimeoutSeconds") : null;
if (s != null) {
readTimeoutSeconds = Integer.parseInt(s);
LOGGER.info("Setting readTimeoutSeconds=" + readTimeoutSeconds);
}

s = conf.getProperty("consoleproxy.defaultBufferSize");
s = conf != null ? conf.getProperty("consoleproxy.defaultBufferSize") : null;
if (s != null) {
defaultBufferSize = Integer.parseInt(s);
LOGGER.info("Setting defaultBufferSize=" + defaultBufferSize);
Comment on lines +37 to +41
/**
* Maximum time (in seconds) a console session is allowed to be idle before it is closed.
* This value should be kept in sync with ConsoleProxy.VIEWER_LINGER_SECONDS.
*/
private static final int MAX_SESSION_IDLE_SECONDS = 180;
Comment on lines 155 to 156
viewer = ConsoleProxy.getNoVncViewer(param, ajaxSessionIdStr, session);
logger.info("Viewer has been created successfully [session UUID: {}, client IP: {}].", sessionUuid, clientIp);
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.

Global setting "consoleproxy.session.timeout " is not honoured

3 participants