Skip to content

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

Open
dheeraj12347 wants to merge 1 commit intoapache:mainfrom
dheeraj12347:fix-12810-consoleproxy-timeout
Open

Honour consoleproxy.session.timeout for noVNC sessions (fixes #12810)#13002
dheeraj12347 wants to merge 1 commit 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.

if (ConsoleProxy.sessionTimeoutMillis <= 0) {
return DEFAULT_MAX_SESSION_IDLE_SECONDS;
}
return ConsoleProxy.sessionTimeoutMillis / 1000;
Comment on lines +48 to +54
private int getMaxSessionIdleSeconds() {
if (ConsoleProxy.sessionTimeoutMillis <= 0) {
return DEFAULT_MAX_SESSION_IDLE_SECONDS;
}
return ConsoleProxy.sessionTimeoutMillis / 1000;
}

Comment on lines +172 to +181
// New: read consoleproxy.session.timeout (milliseconds)
s = conf.getProperty("consoleproxy.session.timeout");
if (s != null) {
try {
sessionTimeoutMillis = Integer.parseInt(s);
LOGGER.info("Setting consoleproxy.session.timeout=" + sessionTimeoutMillis);
} catch (NumberFormatException e) {
LOGGER.warn("Invalid value for consoleproxy.session.timeout: " + s +
", using default " + sessionTimeoutMillis, e);
}
Comment on lines 127 to +131
try {
session.setIdleTimeout(ConsoleProxy.sessionTimeoutMillis);
logger.debug("Set noVNC WebSocket idle timeout to {} ms for session UUID: {}.",
ConsoleProxy.sessionTimeoutMillis, sessionUuid);

}

ConsoleProxyGCThread cthread = new ConsoleProxyGCThread(connectionMap, removedSessionsSet);
ConsoleProxyGCThread cthread = new ConsoleProxyGCThread(connectionMap, removedSessionsSet /*, sessionTimeoutMillis */);
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 3.84615% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.00%. Comparing base (e2d18c0) to head (4a7a6ee).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
...m/cloud/consoleproxy/ConsoleProxyNoVNCHandler.java 0.00% 10 Missing ⚠️
...main/java/com/cloud/consoleproxy/ConsoleProxy.java 10.00% 9 Missing ⚠️
...a/com/cloud/consoleproxy/ConsoleProxyGCThread.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13002      +/-   ##
============================================
- Coverage     18.00%   18.00%   -0.01%     
- Complexity    16464    16472       +8     
============================================
  Files          5977     5976       -1     
  Lines        537726   537881     +155     
  Branches      66026    66053      +27     
============================================
+ Hits          96839    96862      +23     
- Misses       429968   430097     +129     
- Partials      10919    10922       +3     
Flag Coverage Δ
uitests 3.53% <ø> (+<0.01%) ⬆️
unittests 19.17% <3.84%> (-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.

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

2 participants