---
schema_version: "1"
id: 49cbc77562d7ccaf6a58eff5ce0202e3e5c2ca36a2144c94dd4bffd95077efee
title: WebSocket Connection Limit Policy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/gateway/1.13/policies-included-websocket-connection-limit.md
canonical_url: https://docs.mulesoft.com/gateway/1.13/policies-included-websocket-connection-limit
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 95e1427e21c0f85a9013585c129e207c39eab52df8bb68686445b2e1442c749b
description: MuleSoft Documentation Site
release: "1.13"
latest: false
---
---
product: Omni Gateway
version: 1.13
keywords: websocket, connection limit, api gateway, flex gateway, gateway, policy
---

# WebSocket Connection Limit Policy

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

<table><colgroup><col> <col></colgroup><tbody><tr><td><p><strong>Policy Name</strong></p></td><td><p>WebSocket Connection Limit</p></td></tr><tr><td><p><strong>Summary</strong></p></td><td><p>Limits the number of simultaneous WebSocket connections that each API instance allows</p></td></tr><tr><td><p><strong>Category</strong></p></td><td><p>Quality of Service</p></td></tr><tr><td><p><strong>First Omni Gateway version available</strong></p></td><td><p>v1.13.0</p></td></tr><tr><td><p><strong>Release Notes</strong></p></td><td><p><a href="https://docs.mulesoft.com/release-notes/gateway/policies/websocket-connection-limit-release-notes">WebSocket Connection Limit</a></p></td></tr><tr><td><p><strong>Returned status codes</strong></p></td><td><p>429 - <code>Too many WebSocket connections</code></p></td></tr></tbody></table>

## Summary

The WebSocket Connection Limit policy tracks the number of active WebSocket connections for a
specific API instance. Omni Gateway identifies these requests by the `Upgrade: websocket` header and
ignores standard HTTP traffic. The WebSocket connection limit is distributed across Omni replicas.

When a WebSocket upgrade request arrives, Omni Gateway increments the counter to reserve capacity
before forwarding the handshake to the upstream service. If the upstream service doesn’t return a
`101 Switching Protocols` response, Omni Gateway releases the reservation. After a successful
WebSocket connection closes, Omni Gateway decrements the counter.

If the counter reaches the `maximumConnections` limit, Omni Gateway rejects the upgrade request with
a `429` error code.

## Configuring Policy Parameters

### Omni Gateway Local Mode

When you apply the policy via declarative configuration files, Refer to the following policy
definition and table of parameters:

\- policyRef: name: websocket-connection-limit-flex config: maximumConnections: <integer> //
REQUIRED, minimum 1

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Parameter</th><th>Required</th><th>Default Value</th><th>Description</th></tr></thead><tbody><tr><td><div><div><p><code>maximumConnections</code></p></div></div></td><td><div><div><p>Yes</p></div></div></td><td><div><div><p><code>100</code></p></div></div></td><td><div><div><p>Maximum number of simultaneous WebSocket connections allowed for the API instance. The value must be an integer of 1 or greater.</p></div></div></td></tr></tbody></table>

#### Resource Configuration Example

```yaml
- policyRef:
    name: websocket-connection-limit-flex
  config:
    maximumConnections: 500
```

### Managed Omni Gateway and Omni Gateway Connected Mode

When you apply the policy from the UI, the following parameters are displayed:

<table><colgroup><col> <col> <col> <col></colgroup><thead><tr><th>Field</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td><div><div><p>Maximum Connections</p></div></div></td><td><div><div><p>Maximum number of simultaneous WebSocket connections allowed for the API instance.</p></div></div></td><td><div><div><p><code>100</code></p></div></div></td><td><div><div><p>Yes</p></div></div></td></tr></tbody></table>

## See Also

- [Inbound Policies Directory](https://docs.mulesoft.com/gateway/1.13/policies-included-directory)

- [Securing Omni Gateway Instances with Policies](https://docs.mulesoft.com/gateway/1.13/gateway-secure-apis)
