From 4d1d0d9fcb6dce9cf0a4f28f9a932d2d06c56881 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 9 Jun 2026 16:02:17 -0700 Subject: [PATCH] Add warning if we cant reach the vnc server --- src/app/vnc/VncClient.tsx | 45 +++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 14 deletions(-) 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} - - - )}