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.
This commit is contained in:
Torsten Schulz (local)
2025-11-16 00:04:43 +01:00
parent bd95f77131
commit 22e9750e5d

View File

@@ -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);
});