How can I set a timeout for a Ballerina HTTP client?

51 Views Asked by At

I have a Ballerina service that internally calls another service using an HTTP client. Due to a delay in the service response, I need to increase the client timeout. I'm currently encountering the following error due to the client timeout.

error: Idle timeout triggered before initiating inbound response

How can I increase the timeout for a Ballerina HTTP client?

1

There are 1 best solutions below

0
Dimuthu Madushan On

The timeout field in HTTP client configurations is used to gracefully handle response delays that could occur due to network problems or the back-end. The client timeout can be configured in the timeout field of the client configuration in seconds.

http:Client httpClient = new ("localhost:9090", {timeout: 10});

The default timeout is 30 seconds. For more details, refer to the Ballerina HTTP client timeout example.