Recipes
Tune heartbeat timing
WEBSOCKET_HEARTBEAT_INTERVAL_MILLISECONDS=15000
WEBSOCKET_HEARTBEAT_TIMEOUT_MILLISECONDS=5000
Lower the interval for faster dead-peer detection at the cost of more traffic; raise the timeout on high-latency networks to avoid disconnecting slow-but-alive clients.
Disable the heartbeat
WEBSOCKET_HEARTBEAT_ENABLED=false
Useful when the transport or infrastructure already handles keepalive (e.g. an upstream proxy with its own ping/pong).
Change the upgrade path
WEBSOCKET_PATH=/realtime
Implement a custom server adapter
Implement IQWebSocketEngine and register it instead of using @quik/websocket-express:
import type { IQWebSocketEngine } from '@quik/websocket';
class CustomWebSocketEngine implements IQWebSocketEngine {
// send, broadcast, and lifecycle methods per IQWebSocketEngine
}
Checklist
- Keep
websocket.heartbeat.pingMessageType/pongMessageTypeunique from your own application message types to avoid collisions. attachWebSocketHeartbeat()must be called on every client socket that should respond to server pings.