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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user