---
schema_version: "1"
id: b64a62b84243cd71a92613b948945768a6d3c8245294cb801d407a96c201cd22
title: WebSockets Reconnection
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/websockets-connector/latest/websockets-connector-reconnection.md
canonical_url: https://docs.mulesoft.com/websockets-connector/latest/websockets-connector-reconnection
source_site: docs.mulesoft.com
content_type: documentation
content_hash: f7fd5b80aebebc1e5b0fa8eec0f8bbb62c98caf40b5e92a247a1a992ad35286e
description: MuleSoft Documentation Site
release: "1.0"
latest: true
---
---
product: WebSockets Connector
version: 1.0
is-latest-version: true
---

# WebSockets Reconnection

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

WebSockets are based on persistent and stateful connections. A connection can abnormally close in
the lapse between when it was established and its use in an operation due to factors like idle
timeouts, network conditions, and more.

Inbound sockets cannot be automatically reconnected because the remote system must resend the
connection request for the connections to be reestablished.

For outbound sockets however, a reconnection policy can be used to re-establish the connection in
case it drops.

When your Mule app tries to use a WebSocket that has been abnormally closed, for example to send a
message to the socket, reconnection is re-established by replaying the same HTTP request that
originally established the outbound socket. After which, the operation is automatically retried.

The following example shows how to send a reconnection policy using a `<websocket:send>` operation
so that reconnection re-attempts once every second up to 5 times in case the connection is dropped:

```xml
<websocket:send socketId="#[vars.socketId]" config-ref="ws">
    <reconnect count="5" frequency="1000"/>
    <websocket:content>Hello World!</websocket:content>
</websocket:send>
```

## See Also

- [Salesforce Help](https://help.salesforce.com)

- [WebSockets Connector Overview](https://docs.mulesoft.com/websockets-connector/latest/)

- [Connector Configuration](https://docs.mulesoft.com/websockets-connector/latest/websockets-connector-config-topics)
