Improve Socket.IO logging and connection handling

- Enhanced logging during WebSocket upgrade attempts by including specific headers for better debugging.
- Updated frontend socket service to allow forced upgrade attempts after successful polling connections, improving connection reliability.
This commit is contained in:
Torsten Schulz (local)
2025-12-01 08:14:26 +01:00
parent a651113dee
commit 5aa11151cf
2 changed files with 9 additions and 4 deletions

View File

@@ -50,14 +50,17 @@ export const initializeSocketIO = (httpServer) => {
// Verbesserte WebSocket-Upgrade-Logging
io.engine.on('upgrade', (req, socket, head) => {
console.log(`🔄 Socket.IO Upgrade-Versuch: ${req.url}`);
console.log(` Headers:`, req.headers);
console.log(` Upgrade-Header: ${req.headers.upgrade}`);
console.log(` Connection-Header: ${req.headers.connection}`);
console.log(` Sec-WebSocket-Key: ${req.headers['sec-websocket-key']?.substring(0, 20)}...`);
});
io.engine.on('upgradeError', (err, req, socket, head) => {
console.error('❌ Socket.IO Upgrade Error:', err.message || err);
if (req) {
console.error(' URL:', req.url);
console.error(' Headers:', req.headers);
console.error(' Upgrade-Header:', req.headers.upgrade);
console.error(' Connection-Header:', req.headers.connection);
console.error(' Method:', req.method);
}
if (err.stack) {