You're viewing **Apigee Edge** documentation.  
[Go to the
**Apigee X** documentation](http://cloud.google.com/apigee/docs/api-platform/reference/endpoint-properties-reference). info

> [!NOTE]
> **Note:** This document is applicable for Edge Public and Private Cloud users.


This document explains how to configure the connection timeout for the Apigee Edge Message Processors.


The connection timeout represents time for which the Message Processor waits to establish
connection with the target server. The default value of the connection timeout property on the
Message Processor is `3` seconds. This timeout period is applicable to the
backend servers configured in the target endpoint configuration and in the
`ServiceCallout` policy of your API proxy.


The connection timeout for Message Processors can be increased or decreased from the default value of `3` seconds based on your needs. It can be configured in the following ways:

- In the API proxy
  - In the target endpoint
  - In the `ServiceCallout` policy
- On the Message Processor

> [!NOTE]
> **Note:**
>
> 1. The default value of connection timeout property (`3` seconds) has been found to be largely adequate for most backend servers. You should increase the value of this property only if you have deemed it necessary after performing all the possible checks/optimizations on the network and your backend server.
> 2. Ensure that you choose an appropriate value for the connection timeout property based on your needs. Don't set arbitrarily high values for this property.


The following properties control the connection timeout on the Message Processors:

| Property name | Location | Description |
|---|---|---|
| `connect.timeout.millis` | API proxy: - Target endpoint - `ServiceCallout` policy | This is the maximum time which the Message Processor waits to connect with the target server. By default, this property takes the value set for the `HTTPClient.connect.timeout.millis` property on Message Processor, where the default value is `3` seconds. If this property is modified with a new timeout value for the target server associated with an API proxy, then the connect time only for that target server is affected. |
| `HTTPClient.connect.timeout.millis` | Message Processor | This is the maximum time which the Message Processor waits to connect to the target server. This property is used for all the API proxies running on this Message Processor. The default value of this property is `3` seconds. You can either modify this property as explained in [Configuring connection timeout on Message Processors](https://docs.apigee.com/how-to-guides/configuring-connect-timeout-on-message-processors#configure-connect-timeout-on-mp) below, or you can overwrite this value by setting the `connect.timeout.millis `property at the API proxy level. |

## Before you begin


Before you use the steps in this document, be sure you understand the following topics:

- If you aren't familiar with connection timeout, see the `connect.timeout.millis` property description in [TargetEndpoint Transport Property Specification](https://docs.apigee.com/api-platform/reference/endpoint-properties-reference#targetendpointtransportpropertyspecification).
- If you aren't familiar with configuring properties for Edge on Private Cloud, read [How to configure Edge](https://docs.apigee.com/private-cloud/v4.50.00/how-configure-edge).

## Configuring connection timeout in API proxy


The connection timeout can be configured in the API proxy in the following places:

- Target endpoint
- `ServiceCallout` policy

### Configuring connection timeout in target endpoint of API proxy


This section explains how to configure connection timeout in the target endpoint of your API proxy.
The connection timeout can be configured through the property `connect.timeout.millis`,
which represents the connection timeout value in milliseconds.

> [!NOTE]
> **Note:** Configuring the connect time in the target endpoint of your API proxy overrides the default value (`3` seconds) with the new value and affects only the specific API proxy where it is configured. The rest of the API Proxies continue to use the default connect timeout value of `3` seconds.

> [!TIP]
> **Required permissions:** To perform this task, you must have edit access permissions to the specific API proxy in which you would like to configure the connection timeout.

1. In the Edge UI, select the specific API proxy in which you would like to configure the new connection timeout value.
2. Select the specific target endpoint that you want to modify.
3. Add the property `connect.timeout.millis `with an appropriate value under the `<HTTPTargetConnection>` element in the `TargetEndpoint` configuration.


   For example, to change the connection timeout to `5` seconds, add the
   following block of code:

   ```
   <Properties>
     <Property name="connect.timeout.millis">5000</Property>
   </Properties>
   ```


   Since the `connect.timeout.millis` property is in milliseconds, the value for
   `5` seconds is `5000`.


   The following examples show how to configure the connection timeout in the target endpoint
   configuration of your API proxy:

   **Example target endpoint configuration using URL for backend server**

   ```
   <TargetEndpoint name="default">
     <HTTPTargetConnection>
       <URL>https://mocktarget.apigee.net/json</URL>
       <Properties>
         <Property name="connect.timeout.millis">5000</Property>
       </Properties>
     </HTTPTargetConnection>
   </TargetEndpoint>
   ```

   **Example target endpoint configuration using target server**

   ```
   <TargetEndpoint name="default">
     <HTTPTargetConnection>
       <LoadBalancer>
         <Server name="target1" />
         <Server name="target2" />
       </LoadBalancer>
       <Properties>
         <Property name="connect.timeout.millis">5000</Property>
       </Properties>
       <Path>/test</Path>
     </HTTPTargetConnection>
   </TargetEndpoint>
   ```

   > [!NOTE]
   > **Note:**Property values can be only literals. You cannot set values using variables.

4. Save the changes made to your API proxy.

### Configuring connection timeout in ServiceCallout policy of API proxy


This section explains how to configure the connection timeout in the `ServiceCallout`
policy of your API proxy. The connection timeout can be configured through the
`connect.timeout.millis` property, which represents the connect time value in
milliseconds.

> [!NOTE]
> **Note:** Configuring the connection timeout in the `ServiceCallout` policy of the API proxy overrides the default value (`3` seconds) with the new value and affects only the specific `ServiceCallout` policy where it is configured. The rest of the `ServiceCallout` policies and API Proxies continue to use the default connect timeout value of `3` seconds.

> [!TIP]
> **Required permissions:** To perform this task, you must have edit access permissions to the specific API proxy in which you would like to configure the connection timeout for the `ServiceCallout` policy.


To configure the connection timeout in the `ServiceCallout` policy using the
`connect.timeout.millis` property:

1. In the Edge UI, select the specific API proxy in which you would like to configure the new connection timeout value for the `ServiceCallout` policy.
2. Select the specific `ServiceCallout` policy that you want to modify.
3. Add the property `connect.timeout.millis` with an appropriate value under the `<HTTPTargetConnection>` element in the `TargetEndpoint` configuration.


   For example to change the connection timeout to `5` seconds, add the following block of code:

   ```
   <Properties>
     <Property name="connect.timeout.millis">5000</Property>
   </Properties>
   ```


   Since the `connect.timeout.millis` property is in milliseconds, the value for
   `5` seconds is `5000`.


   The following examples show how to configure the connection timeout in the
   `ServiceCallout` policy of your API proxy:

   **Example ServiceCallout policy configuration using URL for backend server**

   ```
   <ServiceCallout name="Service-Callout-1">
     <DisplayName>Service Callout-1</DisplayName>
     <HTTPTargetConnection>
       <Properties>
         <Property name="connect.timeout.millis">5000</Property>
       </Properties>
       <URL>https://mocktarget.apigee.net/json</URL>
     </HTTPTargetConnection>
   </ServiceCallout>
   ```

   **Example ServiceCallout policy configuration using target server**

   ```
   <ServiceCallout enabled="true" name="Service-Callout-1">
     <DisplayName>Service Callout-1</DisplayName>
     <Response>calloutResponse</Response>
     <HTTPTargetConnection>
       <LoadBalancer>
         <Server name="target1" />
         <Server name="target2" />
       </LoadBalancer>
       <Properties>
         <Property name="connect.timeout.millis">5000</Property>
       </Properties>
     <Path>/test</Path>
     </HTTPTargetConnection>
   </ServiceCallout>
   ```

   > [!NOTE]
   > **Note:**Property values can be only literals. You cannot set values using variables.

4. Save the changes made to your API proxy.

## Configuring connection timeout on Message Processors


This section explains how to configure the connection timeout on the Message Processors.
The connection timeout can be configured through the property
`conf_http_HTTPClient.connect.timeout.millis`, which represents the connection timeout
value in milliseconds on the Message Processor component, using the token according to the
syntax described in [How to configure Edge](https://docs.apigee.com/private-cloud/v4.50.00/how-configure-edge).

> [!NOTE]
> **Note:**If a change is made at the Message Processor level, it is important to note that it affects the connection timeout of all the API proxies associated with the organizations and environments served by the specific Message Processors.

> [!TIP]
> **Required permissions:** To perform this task, you must have the following permissions:
>
> - Access to the specific Message Processor, where you would like to configure the connect timeout.
> - Access to create or edit the Message Processor component properties file in the `/opt/apigee/customer/application` folder.


To configure the connection timeout on the Message Processors, do the following:

1. On the Message Processor machine, open the following file in an editor. If it does not already exist, then create it.

   ```
   /opt/apigee/customer/application/message-processor.properties
   ```


   For example, to open the file using `https://en.wikipedia.org/wiki/Vi`,
   enter the following:

   ```
   vi /opt/apigee/customer/application/message-processor.properties
   ```
2. Add a line in the following format to the properties file, substituting a value for <var translate="no">TIME_IN_MILLISECONDS</var>:

   ```
   conf_http_HTTPClient.connect.timeout.millis=TIME_IN_MILLISECONDS
   ```


   For example, to change the connection timeout on the Message Processor to `5` seconds,
   add the following line:

   ```
   conf_http_HTTPClient.connect.timeout.millis=5000
   ```
3. Save your changes.
4. Ensure the properties file is owned by the `apigee` user as shown below:

   ```
   chown apigee:apigee /opt/apigee/customer/application/message-processor.properties
   ```
5. Restart the Message Processor as shown below:

   ```
   /opt/apigee/apigee-service/bin/apigee-service edge-message-processor restart
   ```
6. If you have more than one Message Processor, repeat the above steps on all the Message Processors.

## Verifying connection timeout on Message Processors


This section explains how to verify that the connection timeout has been successfully modified on
the Message Processors.


Even though you use the token `conf_http_HTTPClient.connect.timeout.millis` to set
the connection timeout on the Message Processor, you need to verify if the actual property
`HTTPClient.connect.timeout.millis` has been set with the new value.

1. On the Message Processor machine, search for the property `HTTPTransport.connect.timeout.millis` in the `/opt/apigee/edge-message-processor/conf` directory and check to see if it has been set with the new value as shown below:

   ```
   grep -ri "HTTPClient.connect.timeout.millis" /opt/apigee/edge-message-processor/conf
   ```
2. If the new connection timeout value is successfully set on the Message Processor, then the above command shows the new value in the `http.properties` file.


   The sample result from the above command after you have configured connection timeout to
   `5` seconds is as follows:

   ```
   /opt/apigee/edge-message-processor/conf/http.properties:HTTPClient.connect.timeout.millis=5000
   ```


   In the example output above, notice that the property `HTTPClient.connect.timeout.millis`
   has been set with the new value `5000` in `http.properties`. This indicates
   that the connection timeout is successfully configured to `5` seconds on the Message
   Processor.
3. If you still see the old value for the property `HTTPClient.connect.timeout.millis`, then verify that you have followed all the steps outlined in [Configuring connection timeout on Message Processors](https://docs.apigee.com/how-to-guides/configuring-connect-timeout-on-message-processors#configure-connect-timeout-on-mp) correctly. If you have missed any step, repeat all the steps again correctly.
4. If you are still not able to modify the connection timeout, then contact Google Cloud [Apigee Edge Support](https://docs.apigee.com/api-platform/troubleshoot/support).