WSO2 APIM 3.0.0- endpoint connection timeout solution


Hello everyone, in this post I'll share some of the important configurations of WSO2 API Manager for backend API connection. 

Problem
Recently I faced a strange issue of connection timeout of my backend API endpoint i.e. due to performance issue of my backend API, WSO2 API manager failed to get a response from my backend API and faulted with 'Connection Timeout' error. Below is the response that my API manager sent when such an issue arises-

Http Code: 500 Response: 
<am:fault xmlns:am=\"http://wso2.org/apimanager\">           
    <am:code>101504</am:code>
    <am:type>Status report</am:type>
    <am:message>Runtime Error</am:message>
    <am:description>Send timeout</am:description>
</am:fault>

Cause
Backend API did not respond within the stipulated time frame due to the performance issue of the backend system or network. The default timeout of any API is 300ms (milliseconds)

Solution
We have to Increase the default timeout duration for APIs so that the connection can wait for a certain duration. This can be achieved in two ways-

1. Per API basis
This can be done using the publisher portal as
    a. Open the publisher portal http://host:9443/publisher
    b. Login with proper credentials.

    c. 
Open the API and go to endpoints section as shown below. Further, check the production endpoint and click on the 'gear' icon to open the endpoint settings-    

    d. This shows the default configuration where timeout has been set to 300ms
  
  e. Now you can change the value to a higher one based on your environment. In addition, you can configure a re-try mechanism from here as well by providing the number of retries and the delay as shown below. Save the settings and you are done.

2. Global Configuration
Global configuration settings will apply the configuration for all APIs. In order to do so, you need yo change your deployment.toml file as-

    a. Shutdown the API manager  ( <APIM_HOME>/bin/wso2server.sh stop)

    b. Open file  <APIM_HOME>/repository/conf/deployment.toml

    c. Add or change the value of the timeout as follows
        [synapse_properties]
    synapse.global_timeout_interval = 30000

    d. Add or change the socket timeout value as follows
        [passthru_http]
    http.socket.timeout = 30000

    e. Save the file.

    fStart the API manager  ( <APIM_HOME>/bin/wso2server.sh start)

Reference- https://apim.docs.wso2.com/en/3.0.0/learn/design-api/endpoints/resiliency/endpoint-timeouts

Comments

  1. There are many users who want their payment gateway integration to their online platforms where they accept payments. You need to know all the integration

    ReplyDelete

Post a Comment

Popular posts from this blog

Oracle SOA Suite- Implementing Email Notification

Oracle SOA Suite 12c- PKIX path building failed & unable to find valid certification path to requested target

Migration of Oracle SOA Suite Composite from 11g to 12c