Reputation: 603
AWS API Gateway timeout after around 30 seconds. I connected the API gateway to a lambda function that runs far longer than 30 seconds.
So the API response times out after around ~30 seconds and give back something like a timeout response.
How do I solve this problem and get my response back from Lambda?
Thank you.
Upvotes: 6
Views: 13065
Reputation: 1557
As of June 4 2024, it is possible to raise the integration timeout for REST APIs /API Gateway v1/. Here's my answer with an explanation.
Upvotes: 1
Reputation: 1033
You cannot do anything about api Gateway timeout, it is having hard limit of 30 seconds.
A Solution for this is to use alb with aws lambda, alb is not having any timeout limit.
Another option is polling based as suggested in previous answer by @Maurice.
Upvotes: 2
Reputation: 13197
The API Gateway has a maximum integration timeout of 30 seconds (API Gateway Limits), so there is nothing you can do to increase it.
What you could do is accept the request, create and ID and put it in a queue. Then you send an HTTP 202 Message with the request id back to the client. Now a Lambda function can be triggered from the Queue asynchronously that performs the work. It later persists the results of the query somewhere under the request id (maybe only for a period of time). The client can then use the request ID and poll a second API gateway for the status, which is able to return the response once it's present.
Upvotes: 8