Why Your WebSocket Connection to the GPU Server Keeps Disconnecting
Here are the most likely reasons for disconnections—and practical solutions:
Common Causes & Fixes
1. Idle Timeout from Load Balancers or Proxies
Many environments (Cloudflare, Koyeb, etc.) automatically terminate idle WebSocket connections after a set period—often 100–120 seconds, even when the connection appears active.
What to do: Implement a heartbeat or ping/pong mechanism. For instance, send a ping every 90 seconds to prevent disconnection.
2. Server Updates or Restarts
If you deploy new code or the underlying WebSocket server is restarted, all active connections will be terminated.
What to do: Implement client-side reconnection logic (e.g., exponential backoff, retry loops).
3. Proxy Configuration
Reverse proxies like NGINX must explicitly handle WebSocket traffic with specific headers (Upgrade, Connection) to maintain persistent connections. Missing or misconfigured settings may lead to dropouts.
Tip: Verify your NGINX config includes:
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade";
4. Blocked HTTP Port (Port 80)
If port 80 is blocked, the initial HTTP handshake for ws:// connections cannot complete, causing the connection to fail or disconnect.
What to do: Open port 80 on your firewall/router. If possible, also allow port 443 for wss://
connections.
5. Client or Network Fluctuations
Clients (especially embedded devices) might disconnect due to intermittent network interruptions. A keep-alive message every 30 seconds is a helpful safeguard.
Recommendations for Your Setup
Issue Detected | Recommended Solution |
---|---|
Idle WebSocket disconnects | Send heartbeat (ping/pong) messages at short intervals |
Unexpected disconnects (deploys) | Add robust client-side reconnection logic |
Using reverse proxy (e.g. NGINX) | Ensure proper WebSocket headers are configured |
HTTP port blocked | Open port 80 (and 443 for WSS) in firewall/router |
Intermittent client-side issues | Add client-side keep-alive and connection monitoring |
Contact Support
If you still experience issues after trying these fixes:
- Live Chat: IP ServerOne Customer Portal
- Email: support@ipserverone.com
- Phone: +603-8686 5540