connect fix 3
This commit is contained in:
@ -21,7 +21,15 @@
|
||||
const height = Math.round(window.innerHeight - 40);
|
||||
const dpi = Math.round(window.devicePixelRatio * 96) || 96;
|
||||
|
||||
const tunnelUrl = `${proto}//${window.location.host}/ws/rdp/${hostId}?width=${width}&height=${height}&dpi=${dpi}`;
|
||||
// WICHTIG: die Verbindungsparameter gehoeren NICHT in die Tunnel-URL.
|
||||
// Guacamole.WebSocketTunnel.connect(data) baut die Socket-URL selbst als
|
||||
// `tunnelURL + "?" + data` zusammen. Standen die Parameter schon in der
|
||||
// URL, entstand daraus `...?width=1280&height=800&dpi=96?undefined` -- der
|
||||
// letzte Query-Parameter war damit kein gueltiger Integer mehr, FastAPI
|
||||
// wies den WebSocket noch vor dem Routenhandler ab (HTTP 422) und im
|
||||
// Verbindungslog des Servers tauchte kein einziger Eintrag auf.
|
||||
const tunnelUrl = `${proto}//${window.location.host}/ws/rdp/${hostId}`;
|
||||
const connectParams = `width=${width}&height=${height}&dpi=${dpi}`;
|
||||
const tunnel = new Guacamole.WebSocketTunnel(tunnelUrl);
|
||||
const client = new Guacamole.Client(tunnel);
|
||||
|
||||
@ -32,9 +40,15 @@
|
||||
const labels = ["Idle", "Verbinde ...", "Warte auf Server ...", "Verbunden", "Trenne ...", "Getrennt"];
|
||||
statusEl.textContent = labels[state] || `Status ${state}`;
|
||||
};
|
||||
client.onerror = (err) => {
|
||||
statusEl.textContent = "Fehler: " + (err.message || "unbekannt");
|
||||
const showError = (err) => {
|
||||
// Der Server gibt den Abbruchgrund als WebSocket-Close-Reason mit
|
||||
// (siehe _reject() in app/rdp_proxy/ws_tunnel.py); guacamole-common-js
|
||||
// reicht ihn als Guacamole.Status.message hierher durch.
|
||||
statusEl.textContent = "Fehler: " + ((err && err.message) || "unbekannt");
|
||||
statusEl.classList.add("error");
|
||||
};
|
||||
client.onerror = showError;
|
||||
tunnel.onerror = showError;
|
||||
|
||||
client.onclipboard = (stream, mimetype) => {
|
||||
if (!mimetype.startsWith("text/")) return;
|
||||
@ -48,7 +62,7 @@
|
||||
};
|
||||
};
|
||||
|
||||
client.connect();
|
||||
client.connect(connectParams);
|
||||
|
||||
window.addEventListener("beforeunload", () => client.disconnect());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user