From 22e9750e5d24a48c06eb7d01c7bb4111ab60190b Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Sun, 16 Nov 2025 00:04:43 +0100 Subject: [PATCH] Enhance WebSocket upgrade logging for improved diagnostics This commit updates the `testWebSocket.js` script to include additional logging for the WebSocket upgrade process. It now logs the request path, Sec-WebSocket-Key, response status, and response headers, providing better visibility into the upgrade process. Additionally, error handling has been improved by logging the error code and adding a message for potential server connection issues during timeouts. --- backend/scripts/testWebSocket.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/scripts/testWebSocket.js b/backend/scripts/testWebSocket.js index 4879674..ddd61da 100644 --- a/backend/scripts/testWebSocket.js +++ b/backend/scripts/testWebSocket.js @@ -99,7 +99,13 @@ function testWebSocketUpgrade(host, port, sessionId) { } }; + console.log(` Request-Path: ${path}`); + console.log(` Sec-WebSocket-Key: ${wsKeyBase64.substring(0, 20)}...`); + const wsReq = http.request(options, (res) => { + console.log(` Response Status: ${res.statusCode}`); + console.log(` Response Headers:`, JSON.stringify(res.headers, null, 2)); + if (res.statusCode === 101) { console.log(' ✅ WebSocket-Upgrade erfolgreich!'); console.log(` Status: ${res.statusCode} (Switching Protocols)`); @@ -132,14 +138,15 @@ function testWebSocketUpgrade(host, port, sessionId) { wsReq.on('error', (error) => { console.error(' ❌ WebSocket-Upgrade Fehler:'); console.error(` ${error.message}`); + console.error(` Error Code: ${error.code}`); console.log('\n⚠️ HTTP-Polling funktioniert, aber WebSocket-Upgrade schlägt fehl.'); - console.log(' → Das könnte ein Problem mit der Apache-Konfiguration sein.'); process.exit(0); }); wsReq.setTimeout(5000, () => { wsReq.destroy(); console.error(' ❌ Timeout: Keine Antwort innerhalb von 5 Sekunden'); + console.error(' → Möglicherweise hängt der Server oder die Verbindung wird nicht akzeptiert'); process.exit(1); });