A Lambda shows a task-timed-out error while calling an API endpoint, but the API endpoint log shows that the response was returned within a millisecond.

0

I build my APIs using AWS API Gateway, Lambda, and RDS. I’m calling APIs inside a Lambda, but sometimes I’m getting a task timed-out error. Why it’s happening? I checked all the things below; what else can I do?

  1. The Lambda has enough memory to handle the API calls.
  2. There is no issue with the concurrent request.
  3. The API returns a response successfully.
  4. Everything regarding RDS is OK. DB load, CPU credit, etc.
  5. As all my Lambdas are inside a VPC, there is no issue with the connectivity.
1개 답변
0

Difficult to say without more information. What I would suggest is to had log messages in your function to check what is taking long time.

profile pictureAWS
전문가
Uri
답변함 7달 전
  • Thanks for your comment. I have logs. Below are the steps of the execution.

    1. Inside the Lambda, the API called
    2. There is no task after the API call
    3. After 29 seconds, it shows the "Task timed out ...."
    4. The API logs show the response is returned successfully within a few milliseconds
    5. But the Lambda did not receive the response

    It's not happening always. Once or twice a day. I assumed that it could be a request throttle due to concurrent requests or the RDS resource limit being exceeded, but nothing happened.

  • The network is not a 100% reliable medium. It could be that the API responded, but the response never got to the function. What I would recommend is to put a timeout on the API call and retry in case you do not get the answer in time.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠