3.2 KiB
3.2 KiB
WebSocket Testing Guide
Quick Test - Browser Console
Open the game in your browser and press F12 to open the console. Look for these messages:
Expected Console Messages
🔌 Connecting to WebSocket: wss://echoesoftheashgame.patacuack.net/ws/game/...
✅ WebSocket connected
📨 WebSocket message: connected
Test WebSocket Messages
-
Test Movement:
- Move your character to a new location
- You should see instant state updates (no 5-second delay)
- Check console for:
📨 WebSocket message: state_update
-
Test Combat:
- Enter combat with an NPC
- Attack and observe instant feedback
- Check console for:
📨 WebSocket message: combat_update
-
Test Multi-User (Optional):
- Open game in two different browsers/accounts
- Move one character
- Other browser should see "Player arrived" notification
Verify WebSocket Connection
Run this in your browser console while in the game:
// Check if WebSocket is connected
console.log('WebSocket Status:', window.performance.getEntriesByType('resource').filter(r => r.name.includes('/ws/game/')))
Check Server-Side
Check API logs for WebSocket connections:
cd /opt/dockers/echoes_of_the_ashes
docker compose logs echoes_of_the_ashes_api | grep "WebSocket"
You should see:
🔌 WebSocket connected: username (player_id=123)
Performance Comparison
Before WebSocket
- Open browser DevTools Network tab
- Filter for "game" API calls
- Count requests per minute: Should be ~60 requests (5 endpoints × 12 times/min)
After WebSocket
- Same network tab
- Should see 1 WebSocket connection (ws:// or wss://)
- Regular polling should drop to ~2-6 requests/min (backup polling every 30s)
Troubleshooting
WebSocket Not Connecting
-
Check Token:
console.log('Token:', localStorage.getItem('token'))Should show a JWT token string.
-
Check CORS/Network:
- Look for errors in console
- Check if using HTTPS (wss://) on production
- Check if firewall blocking WebSocket
-
Check API Container:
docker compose logs echoes_of_the_ashes_api | tail -50
Frequent Disconnections
- Check heartbeat is working (every 30s)
- Look for network issues
- Check nginx timeout settings (if using reverse proxy)
Messages Not Updating
- Verify WebSocket shows "connected" in console
- Check if fallback polling is taking over
- Look for errors in API logs
Success Indicators
✅ WebSocket connection established within 2 seconds
✅ Movement updates are instant (<100ms)
✅ Combat actions show immediate feedback
✅ Network tab shows reduced API calls (87% reduction)
✅ No WebSocket errors in console
✅ Auto-reconnect works after network interruption
Next Steps
Once WebSocket is confirmed working:
- Monitor for 24 hours - Check stability
- Gather user feedback - Are updates faster?
- Check server metrics - CPU/memory usage should be lower
- Plan new features - Live chat, parties, real-time map
Known Limitations
- WebSocket requires modern browsers (all current browsers support it)
- Fallback polling ensures old browsers still work
- First connection may take 1-2 seconds (JWT validation)
Good luck! 🎮