Skip to content
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

consoles: Fix constant VNC reconnections when there is a password #2016

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/components/vm/consoles/vnc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class Vnc extends React.Component {
isActionOpen: false,
};

this.credentials = null;

this.connect = this.connect.bind(this);
this.onDisconnected = this.onDisconnected.bind(this);
this.onInitFailed = this.onInitFailed.bind(this);
Expand Down Expand Up @@ -121,7 +123,13 @@ class Vnc extends React.Component {
// postpone rendering until consoleDetail is known and channel ready
return null;
}
const credentials = consoleDetail.password ? { password: consoleDetail.password } : undefined;

// We must pass the very same object to VncConsole.credentials
// on every render. Otherwise VncConsole thinks credentials
// have changed and will reconnect.
if (!this.credentials || this.credentials.password != consoleDetail.password)
this.credentials = { password: consoleDetail.password };

const encrypt = this.getEncrypt();
const renderDropdownItem = keyName => {
return (
Expand Down Expand Up @@ -170,7 +178,7 @@ class Vnc extends React.Component {
path={path}
encrypt={encrypt}
shared
credentials={credentials}
credentials={this.credentials}
vncLogging={ window.debugging?.includes("vnc") ? 'debug' : 'warn' }
onDisconnected={this.onDisconnected}
onInitFailed={this.onInitFailed}
Expand Down