Enhance socket service configuration for improved connection handling

This commit updates the socket service in both the backend and frontend to include explicit path and transport settings for Socket.IO. The backend configuration now allows for upgrades from polling to WebSocket, with defined timeouts for upgrades and pings. The frontend configuration adjusts the transport order and adds a timeout for reconnections, ensuring a more robust and efficient socket connection experience. These changes improve the reliability and performance of real-time communication in the application.
This commit is contained in:
Torsten Schulz (local)
2025-11-15 23:05:27 +01:00
parent 5923ef8bba
commit 1e86b821e8
3 changed files with 123 additions and 3 deletions

View File

@@ -8,7 +8,17 @@ export const initializeSocketIO = (httpServer) => {
origin: true,
credentials: true,
methods: ['GET', 'POST']
}
},
// Wichtig für Reverse Proxy (Nginx): Path und Transports explizit setzen
path: '/socket.io/',
transports: ['websocket', 'polling'],
// Erlaube Upgrade von polling zu websocket
allowUpgrades: true,
// Timeout für Upgrade
upgradeTimeout: 10000,
// Ping-Timeout für Verbindungen
pingTimeout: 60000,
pingInterval: 25000
});
io.on('connection', (socket) => {