WebSocket Proxy
Look up what WebSocket Proxy needs on an application, the upgrade headers, the errors it returns, and its connection limits.
WebSocket, specified in RFC 6455, is a protocol that keeps one bidirectional TCP connection open between a client and a server, so both sides exchange data in real time after a single handshake, without restarting the connection. WebSocket Proxy carries that connection between your users and your origin through an application, which works as a reverse proxy. Use it for real-time applications such as online games, chat, notifications, and live streaming. WebSocket Proxy fits when the WebSocket server is your origin, because the application only carries the connection to it. When a function should act as the WebSocket server or client itself, use the WebSocket API instead, which handles a server-side upgrade with upgradeWebSocket().
Availability
WebSocket Proxy is available to customers with Business, Enterprise, or Mission-Critical Support, and to customers with a Reserved Capacity or Saving Plan contract. To request access to WebSocket Proxy, contact Technical Support.
Client and origin support
A WebSocket connection through an application needs native WebSocket support at both ends: the client that opens the connection and the server at the origin. Most browsers support WebSocket natively. For the list of browsers with native support, refer to Can I use.
Upgrade headers
An application with WebSocket Proxy enabled reads two request headers to decide whether a request opens a WebSocket connection. By default, it treats every request that carries both headers, with the values in this table, as a WebSocket connection and proxies it to the origin.
| Header | Value |
|---|---|
Upgrade | websocket |
Connection | upgrade |
When the client sends either header with another value, or omits one of them, the application does not carry out the upgrade toward the origin.
The rules of a firewall can inspect a WebSocket request before the upgrade completes.
Errors
A WebSocket connection through an application completes with 101 Switching Protocols. Any other status means that the upgrade did not complete, even a status from the 2xx or 3xx success families:
| Status | Cause | What to do |
|---|---|---|
Any status other than 101 | The client, the application, or the origin did not complete the WebSocket connection | Check that the client and the origin support WebSocket natively, and that the request carries both upgrade headers with their values |
Limits
Azion recycles keepalive connections on its servers approximately every 15 minutes, and it can terminate an active WebSocket connection that stays open past that time. Your application then needs to detect the closed connection and reestablish it. For the maximum connection time of a WebSocket connection, and how to request a higher limit for your plan, refer to Applications limits.