# WebSocket Proxy

import DocButton from '~/components/webkit/DocButton.vue';

The **WebSocket Proxy** allows you to establish the WebSocket communication protocol between your origin and your users under the reverse proxy architecture. This type of protocol consists of a single bidirectional TCP connection that allows data to be exchanged in real time via a single handshake without the need to restart the connection.

WebSockets are designed to minimize latency and increase efficiency, and are suitable for applications that exchange data in real time, such as online games, chat platforms, notifications, and live streaming services. See the [WebSocket protocol specification](https://datatracker.ietf.org/doc/html/rfc6455) for more information.

:::note
At the moment, this capability is exclusively accessible to customers with **Business**, **Enterprise**, and **Mission-Critical** Support, also available in the **Reserved Capacity** or **Saving Plan** contracts. [Contact the Support team](https://tickets.azion.com/en/support/loginen/support/login/new) to request access to this capability.
:::

:::caution  
Due to their nature as a bidirectional open connection, WebSocket Proxy is incompatible with the use of the [Image Processor](/en/documentation/products/build/applications/image-processor/), [Cache](/en/documentation/products/build/applications/cache/) or [Tiered Cache](/en/documentation/products/build/applications/cache/tiered-cache/) modules.
:::

## Implementation

| Scope | Resource |
| --- | --- |
| Applications first steps| [First steps](/en/documentation/products/build/applications/first-steps/)  |
| Functions WebSocket API| [WebSocket API](/en/documentation/runtime/api-reference/websocket/)  |
| Debug Rules| [Debug Rules](/en/documentation/products/guides/debug-rules/)  |

## Functions WebSocket Support

Azion Functions supports **WebSocket API**, allowing your Applications to act as a full WebSocket server or client and proxy bidirectional traffic to backend services. This unlocks real-time use cases such as chat, multiplayer games, telemetry dashboards, and AI inference streams—all served directly from the edge for sub-second latency.

**Key Features:**
- **Server & client modes**: Use `upgradeWebSocket()` for server-side handlers or the standard WebSocket(url) API for outbound connections
- **Broadcast helpers**: Easily fan-out messages to all connected clients with minimal code
- **Firewall support**: Firewall rules can inspect WebSocket traffic before the upgrade process is finalized

<DocButton href="/en/documentation/runtime/api-reference/websocket/" label="Go to WebSocket API reference" kind="secondary" target="_blank" size="medium" />

## Requirements

Your client and server must support the WebSocket connection natively for the protocol to be implemented in your applications. On the client side, most browsers include native WebSocket support. See the [complete list of browsers with WebSocket support](https://caniuse.com/websockets).

### Upgrade headers

The origin application must inject the `Upgrade: websocket` and `Connection: upgrade` HTTP headers for the connection to be successfully established. If the `Connection` and `Upgrade` headers are sent by the client with values other than those specified above or one of them isn't present, the connection upgrade in the user request to the origin won't be carried out.

---

## Error treatments

By default, an application that has the **WebSocket Proxy** module enabled will consider any request received with the headers `Upgrade: websocket` and `Connection: upgrade` to be a websocket connection and will forward them to the origin. It's recommended that the application itself controls the headers in cases where the protocol should be used.

A valid WebSocket connection will return the status `101 Switching Protocols`. If this isn't the status received, even if it's among the `2xx` or `3xx` family of success statuses, it's likely that the client request, the application, or the origin server didn't complete the Websocket connection. In this case, you should review the [connection upgrade requirements](#requirements) and make the necessary adjustments.

---

## Limits

:::tip
**Increase limits** <br></br>
You can request to increase the limits based on your plan. Contact the [technical support team](/en/documentation/services/support/) to request it.
:::

These are the **default limits**:

| Scope | Limit |
| --- | --- |
| Maximum connection time¹ | 15 minutes |

> ¹ Azion recycles [keepalive connections](/en/documentation/products/build/applications/#keepalive-timeout) on its servers approximately every *15 minutes*. Active WebSocket connections may be terminated if they exceed this range. In such cases, your application should handle these scenarios and reestablish the connection as needed.