-
-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Hi!
First off, thanks for creating Rahoot! It's an awesome and works great on desktop.
I'm running Rahoot with friends and family, I noticed a small issue with mobile devices:
The Issue
When mobile users (iOS/Android) switch apps or their screen dims, they get disconnected from the game and have to rejoin. On desktop, everything works perfectly!
What happens:
- User is playing on their phone
- They switch to another app briefly (or screen locks)
- When they come back, they're disconnected
- They have to rejoin the game
What we'd expect:
- The app automatically reconnects when they come back
- Their session is restored so they can keep playing
Why This Happens
Mobile browsers suspend connections when apps are backgrounded to save battery. This is normal behavior, but Socket.IO has built-in reconnection features that can handle this gracefully.
Possible Solution
Would it be possible to add some environment variables to configure Socket.IO reconnection? Something like:
# Enable automatic reconnection
SOCKET_RECONNECTION=true
SOCKET_RECONNECTION_ATTEMPTS=Infinity
# Server timeout (keep connections alive longer)
SOCKET_PING_TIMEOUT=60000Then the Socket.IO client could be configured to automatically reconnect:
const socket = io(SOCKET_URL, {
reconnection: true,
reconnectionAttempts: Infinity,
reconnectionDelay: 1000,
transports: ['websocket', 'polling']
});
socket.on('reconnect', () => {
// Restore the user's session
});Deployment Info
- Environment: Kubernetes with nginx ingress
- Tested on: iOS Safari, Android Chrome
- Docker image: ralex91/rahoot:latest
Happy to Help!
I'm running this in production and would be glad to:
- Test any fixes
- Provide more details if needed
- Help with a PR if you'd like
Thanks again for this great project! 🎉
Temporary workaround: Currently telling mobile friends to keep the app in foreground during games.
Reference: Socket.IO reconnection docs: https://socket.io/docs/v4/client-options/#reconnection