---
schema_version: "1"
id: 59cc441f4d46530daa0093e8c318d40825d905ccb40f112ec99126484d60a6e4
title: Reconnection Strategies
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.9/reconnection-strategy-about.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.9/reconnection-strategy-about
source_site: docs.mulesoft.com
content_type: documentation
content_hash: f5fe2b417b33a36a73601314cc567362e5ddf8d80802f3a23fefd0aa42780676
description: MuleSoft Documentation Site
release: "4.9"
latest: false
---
---
product: Mule Runtime
version: 4.9
keywords: anypoint, studio, reconnection strategies, reconnection strategy, retry policies, retry
---

# Reconnection Strategies

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

When an operation in a Mule application fails to connect to an external server, the default behavior
is for the operation to fail immediately and return a connectivity error.

For example, if an operation in Anypoint Connector for FTP (FTP Connector) fails to connect to an
FTP server, the operation throws an `FTP:CONNECTIVITY` error. The error name reflects the namespace
that is specific to the connector, such as `FTP:CONNECTIVITY`, or `DB:CONNECTIVITY` (for Anypoint
Connector for Database (Database Connector).

You can modify this default behavior by configuring a reconnection strategy for the operation.

> [!NOTE] Operation executions don’t trigger the reconnection strategy configured at the FTP
> Connector when failing with connectivity errors. In this example, the reconnection strategy
> applies only to the connection that `ftp:listener` needs to establish with the FTP server to query
> for new or updated files.

## Configure an Operation Reconnection Strategy

You can configure a reconnection strategy for an operation either by modifying the operation
properties or by modifying the configuration of the global element for the operation. For example,
you can configure a reconnection strategy in an FTP Connector configuration:

![An FTP configuration with reconnection strategy](/mulesoft/current/en-us/mule-runtime/4.9/_images/mruntime-reconnection-strategy-ftp.png)

The following are the available reconnection strategies and their behaviors:

- **None**

  Is the default behavior, which immediately returns a connectivity error if the attempt to connect
  is unsuccessful

- **Standard** (`reconnect`)

  Sets the number of reconnection attempts and the interval at which to execute them before
  returning a connectivity error

- **Forever** (`reconnect-forever`)

  Attempts to reconnect continually at a given interval

## Example XML Reconnection Strategy Configurations

The following examples show different types of reconnection strategies and their configurations:

- Standard reconnection strategy example

  The following example illustrates a Standard reconnection strategy in an FTP connector
  configuration, setting the count of reconnection attempts before failing to `5` and setting
  `failsDeployment` to `true`, which causes the application deployment to fail if the connection
  test fails. Because a frequency is not specified, the retry interval is the default of every 2000
  ms:

  ```xml
  <ftp:config name="FTP_Config" doc:name="FTP Config" >
    <ftp:connection host="ftp.someftphost.com" port="21" username="myusername" password="mypassword" >
      <reconnection failsDeployment="true" >
        <reconnect count="5"/>
      </reconnection>
    </ftp:connection>
  </ftp:config>
  <flow name="reconnectionsFlow" >
    <ftp:listener doc:name="On New or Updated File" config-ref="FTP_Config">
      <scheduling-strategy >
        <fixed-frequency />
      </scheduling-strategy>
    </ftp:listener>
  </flow>
  ```

- Forever reconnection strategy example

  The following example sets a Forever reconnection strategy in an FTP connector configuration by
  which the connector attempts to reconnect every 4000 ms for as long as the application runs:

  ```xml
  <ftp:connection host="ftp.someftphost.com" port="21" username="myusername" password="mypassword" >
    <reconnection>
      <reconnect-forever frequency="4000"/>
    </reconnection>
  </ftp:connection>
  ```

## Reconnection Strategy Reference

Following are the different configuration attributes for each reconnection strategy you can
configure by editing your Mule application’s XML configuration file:

- Attributes of `<reconnection>`

  <table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><p><code>failsDeployment</code></p></td><td><p>boolean</p></td><td><p>no</p></td><td><p>false</p></td><td><p>If <code>true</code>, causes the deployment to fail when the test connection fails</p></td></tr></tbody></table>

- Attributes of `<reconnect>`

  <table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><p><code>blocking</code></p></td><td><p>boolean</p></td><td><p>no</p></td><td><p>true</p></td><td><p>If <code>false</code>, the reconnection strategy runs in a separate, nonblocking thread</p></td></tr><tr><td><p><code>frequency</code></p></td><td><p>long</p></td><td><p>no</p></td><td><p>2000</p></td><td><p>How often (in ms) to reconnect</p></td></tr><tr><td><p><code>count</code></p></td><td><p>integer</p></td><td><p>no</p></td><td><p>2</p></td><td><p>How many reconnection attempts to make</p></td></tr></tbody></table>

- Attributes of `<reconnect-forever>`

  <table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><p><code>blocking</code></p></td><td><p>boolean</p></td><td><p>no</p></td><td><p>true</p></td><td><p>If <code>false</code>, the reconnection strategy runs in a separate, nonblocking thread.</p></td></tr><tr><td><p><code>frequency</code></p></td><td><p>long</p></td><td><p>no</p></td><td><p>2000</p></td><td><p>Specifies how often (in ms) to reconnect.</p></td></tr></tbody></table>

## See Also

- [Core Components](https://docs.mulesoft.com/mule-runtime/4.9/about-components)

- [Connectors and Modules](https://docs.mulesoft.com/connectors/)

- [Configure Global Elements](https://docs.mulesoft.com/mule-runtime/4.9/global-elements)
