Configuring I/O timeout on Message Processors

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

This document explains how to configure the I/O timeout for the Apigee Edge Message Processors.

The I/O timeout on the Message Processor represents the time for which the Message Processor waits either to receive a response from the backend server or for the socket to be ready to write a request to the backend server, before it times out.

The Message Processor I/O timeout default value is 55 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 I/O timeout for Message Processors can be increased or decreased from the default value of 55 seconds based on your needs. It can be configured in the following places:

  • In the API proxy
    • Target endpoint
    • ServiceCallout policy
  • On the Message Processor

The following properties control the I/O timeout on the Message Processors:

Property Name Location Description
io.timeout.millis

API proxy:

  • Target endpoint
  • Service Callout policy

This is the maximum time for which the Message Processor does the following:

  • Waits to receive a response from the backend server, after establishing the connection and sending the request to the backend server OR
  • Waits for the socket to be ready for the Message Processor to send the request to the backend server.

If there is no response from the backend server within this timeout period, then the Message Processor times out.

By default, this property takes the value set for the HTTPTransport.io.timeout.millis property on the Message Processor. The default value is 55 seconds.

If this property is modified with a new timeout value for a specific API proxy, then only that API proxy is affected.

HTTPTransport.io.timeout.millis Message Processor

This is the maximum time for which the Message Processor does the following:

  • Waits to receive a response from the backend server, after establishing the connection and sending the request to the backend server OR
  • Waits for the socket to be ready for the Message Processor to send the request to the backend server.

If there is no response from the backend server within this timeout period, then the Message Processor times out.

This property is used for all the API Proxies running on this Message Processor.

The default value of this property is 55 seconds.

You can either modify this property as explained in Configuring I/O timeout on Message Processors, or you can overwrite this value by setting the io.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:

Configuring I/O timeout in API proxy

The I/O timeout can be configured in the following API proxy places:

  • Target endpoint
  • ServiceCallout policy

Configuring I/O timeout in target endpoint of API proxy

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

  1. In the Edge UI, select the specific API proxy in which you would like to configure the new I/O timeout value.
  2. Select the specific target endpoint that you want to modify.
  3. Add the property io.timeout.millis with an appropriate value under the <HTTPTargetConnection> element in the TargetEndpoint configuration.
  4. For example, to change the I/O Timeout to 120 seconds, add the following block of code:

        <Properties>
          <Property name="io.timeout.millis">120000</Property>
        </Properties>
    

    Since the io.timeout.millis property is in milliseconds, the value for 120 seconds is 120000.

    The following examples show how to configure the I/O 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="io.timeout.millis">120000</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="io.timeout.millis">120000</Property>
        </Properties>
        <Path>/test</Path>
      </HTTPTargetConnection>
    </TargetEndpoint>
    
  5. Save the changes made to your API proxy.

Configuring I/O timeout in ServiceCallout policy of API proxy

This section explains how to configure the I/O timeout in the ServiceCallout policy of your API proxy. The I/O timeout can be configured through either the <Timeout> element or the io.timeout.millis property. Both the <Timeout> element and the io.timeout.millis property represent the I/O timeout values in milliseconds.

You can configure the I/O timeout in the ServiceCallout policy using one of the following methods:

  • <Timeout> element.
  • io.timeout.millis property.

Timeout element

To configure the I/O timeout in the ServiceCallout policy using the <Timeout> element, do the following:

  1. In the Edge UI, select the specific API proxy in which you would like to configure the new I/O timeout value for the ServiceCallout policy.
  2. Select the specific ServiceCallout policy that you want to modify.
  3. Add the element <Timeout> with an appropriate value under the <ServiceCallout> configuration.

    For example, to change the I/O timeout to 120 seconds, add the following line of code:

        <Timeout>120000</Timeout>
    

    Since the <Timeout> element is in milliseconds, the value for 120 seconds is 120000.

    The following example shows how to configure the I/O timeout in the ServiceCallout policy using the <Timeout> element:

    Example ServiceCallout policy configuration using URL for backend server

    <ServiceCallout name="Service-Callout-1">
        <DisplayName>ServiceCallout-1</DisplayName>
        <Timeout>120000</Timeout>
        <HTTPTargetConnection>
            <Properties/>
            <URL>https://mocktarget.apigee.net/json</URL>
        </HTTPTargetConnection>
    </ServiceCallout>
    
  4. Save the changes made to your API proxy.

io.timeout.millis property

To configure the I/O timeout in the ServiceCallout policy using the io.timeout.millis property, do the following:

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

    For example, to change the I/O timeout to 120 seconds, add the following block of code:

        <Properties>
          <Property name="io.timeout.millis">120000</Property>
        </Properties>
    

    Since the io.timeout.millis property is in milliseconds, the value for 120 seconds is 120000.

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

    Example ServiceCallout policy configuration using URL for backend server

    <ServiceCallout name="Service-Callout-1">
        <DisplayName>ServiceCallout-1</DisplayName>
        <HTTPTargetConnection>
          <Properties>
            <Property name="io.timeout.millis">120000</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>ServiceCallout-1</DisplayName>
        <Response>calloutResponse</Response>
        <HTTPTargetConnection>
            <LoadBalancer>
                <Server name="target1" />
                <Server name="target2" />
            </LoadBalancer>
            <Properties>
                <Property name="io.timeout.millis">120000</Property>
            </Properties>
            <Path>/test</Path>
        </HTTPTargetConnection>
    </ServiceCallout>
    
  4. Save the changes made to your API proxy.

Configuring I/O timeout on Message Processors

This section explains how to configure the I/O timeout on the Message Processors. The I/O timeout can be configured through the property HTTPTransport.io.timeout.millis, which represents the I/O timeout value in milliseconds on the Message Processor component, using the token as per the syntax described in How to configure Edge.

To configure the I/O 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 vi, enter the following command:

    vi /opt/apigee/customer/application/message-processor.properties
    
  2. Add a line in the following format to the properties file, substituting a value for TIME_IN_MILLISECONDS:
    conf_http_HTTPTransport.io.timeout.millis=TIME_IN_MILLISECONDS
    

    For example, to change the I/O timeout on the Message Processor to 120 seconds, add the following line:

    conf_http_HTTPTransport.io.timeout.millis=120000
    
  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 I/O timeout on Message Processors

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

Even though you use the token conf_http_HTTPTransport.io.timeout.millis to set the I/O timeout on the Message Processor, you need to verify if the actual property HTTPTransport.io.timeout.millis has been set with the new value.

  1. On the Message Processor machine, search for the property HTTPTransport.io.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 "HTTPTransport.io.timeout.millis" /opt/apigee/edge-message-processor/conf
    
  2. If the new I/O timeout value is successfully set on the Message Processor, then the above command shows the new value in the http.properties file.
  3. The sample result from the above command after you have configured I/O timeout to 120 seconds is as follows:

    /opt/apigee/edge-message-processor/conf/http.properties:HTTPTransport.io.timeout.millis=120000
    

    In the example output above, notice that the property HTTPTransport.io.timeout.millis has been set with the new value 120000 in http.properties. This indicates that the I/O timeout is successfully configured to 120 seconds on the Message Processor.

  4. If you still see the old value for the property HTTPTransport.io.timeout.millis, then verify that you have followed all the steps outlined in Configuring I/O timeout on Message Processors correctly. If you have missed any step, repeat all the steps again correctly.
  5. If you are still not able to modify the I/O timeout, then please contact Apigee Edge Support.

What’s next?

Learn about Configuring I/O timeout on Routers