What is WebSocket?
Short answer
WebSocket is the protocol that starts with an HTTP request, is upgraded with the Upgrade: websocket header and the 101 Switching Protocols response, and then turns into a bidirectional connection that stays open for a long time; it is used in applications such as chat, live notifications and real-time data streams. After the upgrade, the connection leaves the HTTP request-response pattern, and both sides can send messages whenever they want. In TR7, the HTTP vService carries WebSocket traffic without requiring a separate setting. How long the upgraded connection stays open without data flow is determined by the Tunnel(Websocket) Timeout field in the Timeouts profile (default 120 seconds); the profile is assigned to the vService in the Timeout field.
Where It Is Used in TR7
| Where | Field / label | What for |
|---|---|---|
| Load Balancer → Profiles (L4-L7 Behavior Sets) → Timeouts | Tunnel(Websocket) Timeout (seconds; default 120, 0–60,000) | How long the upgraded connection stays open without data flow in either direction |
| HTTP vService form → Details | Timeout | Assigning the Timeouts profile to the vService; if no profile is assigned, the default Timeouts profile values apply |
Publishing WebSocket behind TR7: Can I load balance WebSocket traffic? · Dropped connections: My WebSocket connections drop after a certain time; what should I do?
How Does It Work?
- The client sends a normal HTTP/1.1 request; the request contains the
Connection: UpgradeandUpgrade: websocketheaders. - If the server responds with
101 Switching Protocols, the connection switches to WebSocket. - Over the same TCP connection, both sides send each other messages in frames; the connection stays open until one of the sides closes it or the idle time expires.
The protocol is defined in: RFC 6455 · The WebSocket Protocol.
Common Misconceptions
- "WebSocket requires a separate vService type or option." The HTTP vService carries the upgrade on its own; there is no separate WebSocket setting to turn on.
- "If the connection drops, the HTTP keepalive timeout must be increased." The idle time of the upgraded connection is determined by Tunnel(Websocket) Timeout; HTTP Keepalive Timeout limits only the wait between two HTTP requests.
- "Tunnel(Websocket) timeout is the total lifetime of the connection." The time is an idle time; the counter restarts each time data flows on the connection.
How it is done in the documentation
