diff --git a/src/app/vnc/VncClient.tsx b/src/app/vnc/VncClient.tsx
index 7d4291e1b..dc91e05ef 100644
--- a/src/app/vnc/VncClient.tsx
+++ b/src/app/vnc/VncClient.tsx
@@ -116,6 +116,30 @@ export default function VncClient({
disconnect();
+ const proxyAddress = `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}/gateway/vnc`;
+ const base = proxyAddress.replace(/\/$/, "");
+ const params = new URLSearchParams({
+ host: target.ip,
+ port: String(target.port),
+ authToken: target.authToken
+ });
+
+ try {
+ const checkParams = new URLSearchParams(params);
+ checkParams.set("checkOnly", "1");
+ const response = await fetch(`${base}?${checkParams.toString()}`);
+ if (!response.ok) {
+ const detail = (await response.text()).trim();
+ setConnectError(detail || t("sshErrorConnectionClosed"));
+ setConnecting(false);
+ return;
+ }
+ } catch {
+ setConnectError(t("sshErrorWebSocket"));
+ setConnecting(false);
+ return;
+ }
+
let RFB: new (
target: HTMLElement,
url: string,
@@ -136,13 +160,6 @@ export default function VncClient({
return;
}
- const proxyAddress = `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}/gateway/vnc`;
- const base = proxyAddress.replace(/\/$/, "");
- const params = new URLSearchParams({
- host: target.ip,
- port: String(target.port),
- authToken: target.authToken
- });
const wsUrl = `${base}?${params.toString()}`;
screenRef.current.innerHTML = "";
@@ -270,6 +287,13 @@ export default function VncClient({
)}
/>
+ {connectError && (
+
+
+ {connectError}
+
+
+ )}
- {connectError && (
-
-
- {connectError}
-
-
- )}