Troubleshooting Gateway Timeout When Triggering SAP BTP APIM Endpoint

SAP BTP requires no introduction, being well-established among SAP developers and consultants. In this brief discussion, we'll address an issue encountered within SAP APIM (API Management), a component of the SAP BTP Integration Suite, which may result in intermittent errors such as 'broken pipe error' or 'gateway timeout.

Scenario description

You're utilizing APIM on your BTP instance to expose the Integration Flow Endpoint as an API and test the flow. This API initiates an HTTP request to a third-party system, awaits a response for processing, and then forwards the response message to the client.

See. Expose Integration Flow Endpoint as API and Test the Flow
Simple representation of the iFlow

Issue description

Upon triggering the API's endpoint via, for example, the Postman client, you may encounter a 'gateway timeout' error if the HTTP call to the external system exceeds or equals 55 seconds.


To illustrate, let's use an API that triggers a simple iflow, including a Groovy script step simulating an HTTP call lasting for 55 seconds.

See. Developing Script and Script Collection

Upon triggering the exposed API endpoint, a 'Gateway timeout' error occurs after 55 seconds.

Adjusting the timeout value to 54 seconds results in a successful API trigger with a 200 response code, indicating successful processing and response retrieval.

Root cause

The default timeout value in SAP APIM is set to 55 seconds, intended to accommodate request, response, and processing times. Exceeding this threshold may result in timeout errors, including the 'broken pipe error'.

See SAP Note 3336835 - Custom timeout at API Management level
See Limits in API Management
Basically it's not recommended to have timeout value of more than 55sec for a proxy. 55 seconds has been set as the default IO timeout so that if there is no data to read or if the socket is not ready to write data within 55 seconds, the transaction is treated as a timeout.
PDF version of SAP Note 3336835 - Custom timeout at API Management level
As of 24 Apr, 2024 the above SAP Note has been removed by the vendor.

To address this issue, you may consider options such as:

  1. Requesting an increase in the timeout limit to 5 minutes through an OSS message to SAP
  2. Optimizing HTTP requests to reduce processing time and enhance efficiency.
  3. Redesigning your flow implementing the asynchronous call as per description from the SAP Note SAP Note 3336835 - Custom timeout at API Management level