# WebSocket Proxy

WebSocket, specified in [RFC 6455](https://datatracker.ietf.org/doc/html/rfc6455), 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](/en/documentation/platform/applications/), 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](/en/documentation/devtools/runtime/api-reference/websocket/) 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](/en/documentation/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](https://caniuse.com/websockets).

## 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](/en/documentation/platform/applications/websocket/#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](/en/documentation/platform/applications/limits/).

---

## Related resources

- [Applications quickstart](/en/documentation/platform/applications/quickstart.md): The first application, before you proxy WebSocket connections through it.
- [Connectors](/en/documentation/platform/connectors.md): Where the origins an application sends requests to are defined.
- [Debug rules](/en/documentation/guides/application-development/getting-started/debug-rules.md): How to find which rules of an application run on a request.
- [Troubleshoot Applications](/en/documentation/platform/applications/troubleshooting.md): The symptoms an application can produce, and how to find their cause.
