Back to blog

Why AWS ALB Drops WebSocket Connections and How to Build Resilient Real-Time Apps

Learn why the 60-second AWS ALB idle timeout quietly kills WebSocket connections in voice and AI systems, and how to implement solid reconnection and heartbeats.

Oct 31, 2026
7
directions
notes from delivery practice
3
levels
strategy · process · tools
1
library
guides · checklists · cases
See cases

The 60-Second Mystery: Why WebSockets Drop Silently

When building interactive web platforms — whether voice-driven AI interfaces, complex SaaS tools, or real-time trading dashboards — engineering teams frequently turn to WebSockets for low-latency, bidirectional communication. Yet in production environments hosted on AWS, businesses often observe mysterious session drops that degrade customer experience while leaving zero 5xx errors on the server.

The root cause is frequently the AWS Application Load Balancer (ALB) default configuration: an idle timeout of 60 seconds. If not a single byte traverses the socket in either direction for a full minute, the load balancer abruptly severs the TCP connection. From the browser's perspective, this triggers a generic Close Code 1006 — the exact error normally associated with lost internet connectivity.

The Silence Trap in Voice and Conversational Systems

Real-time applications, particularly those utilizing voice activity detection (VAD), are particularly vulnerable. To preserve bandwidth and cloud processing costs, clients only stream microphone data when speech is present. When a user pauses to contemplate a complex answer:

  • The client stops sending audio frames because the environment is quiet.
  • The backend server waits silently for incoming audio.
  • The data channel reaches complete standstill for 60 seconds.
  • The ALB terminates the connection without issuing a proper WebSocket close handshake.

If the client application blindly reconnects by instantiating a brand-new session, the user gets reset back to step one. In a commercial application, this friction directly hits retention and user trust.

The Engineering Strategy for Rock-Solid WebSockets

Resolving unexpected socket closures requires addressing both protocol traffic patterns and session continuity. At ViAcore, we rely on a three-tier mitigation strategy:

1. Server-Side Protocol Heartbeats

The native Browser WebSocket API does not expose direct control over raw protocol-level Ping frames. The most resilient pattern is initiating regular pings from the backend server every 20 to 25 seconds. Modern browsers respond with a Pong frame automatically. This negligible byte exchange keeps the ALB socket pipeline active without inflating cloud bills or complicating client logic.

2. Extended Infrastructure Timeouts

Adjusting the idle_timeout parameter within your AWS ALB configuration (e.g., expanding from 60 seconds to 300 seconds) provides an essential safety buffer. However, infrastructure tuning alone is insufficient: intermediary corporate proxies, CDN layers, or mobile carrier NAT gateways enforce their own undocumented timeout limits. Heartbeat pings remain non-negotiable.

3. Resilient Session Resumption

Network interruptions will inevitably occur in mobile environments. Rather than treating every new socket handshake as a fresh interaction, implement stateful recovery:

  • Issue a short-lived recovery token upon initial connection.
  • Store conversation state in a distributed cache (such as Redis).
  • On reconnect, present the token to seamlessly rejoin the existing session context.

By auditing connection idle patterns and hardening reconnection logic, digital products achieve enterprise-grade reliability even under unpredictable network conditions.

Services on this topic

Need this for your project?

Development turnkey: analysis → implementation → launch → support. Tell us about your task — we will reply with an estimate.

About the direction

Relevant articles