272
WebSocket
also socket, upgrade handshake
A WebSocket is a long-lived connection. Auth happens on the upgrade, and a slow client must not fill memory.
What is WebSocket?
A WebSocket starts as an HTTP upgrade and then carries frames both ways. The handshake is where you check the cookie or a one-time ticket. A token you meant to check on every message will be forgotten on one path. Heartbeats tell you the peer is gone. Reconnect needs backoff. If the client reads slowly, you apply backpressure instead of buffering forever.
Why does WebSocket matter when vibe coding?
The draft uses a WebSocket for one request and response, or it trusts the first message as login and never checks the handshake. A disconnected client leaves a goroutine writing into a buffer.
How do you do WebSocket?
Authenticate the upgrade. Heartbeat. Bound the send buffer. Reconnect with backoff and a fresh ticket. Use plain HTTP when one response would do.
How do you ask a model for WebSocket?
Open a WebSocket for (stream). Authenticate the upgrade. Heartbeat. Apply backpressure when the client is slow. Reconnect with backoff. Do not use a socket for a single request and response.
What goes wrong with WebSocket?
A load balancer that drops idle connections at 60 seconds while your heartbeat is at 90. The socket dies and only the client notices.