Random "Socket hangup" calling Dynamodb in Lambda

0

We use lambda functions in dotnet and nodejs. The functions are attached to a VPC. Sometimes, when trying to call dynamodb from the lambda, we hit a "socket hangup". We did not found any way to prevent this, it's annoying because we use datadog to detect abnormal behaviours on production and it raise alerting. Do you know what could cause this "socket hangup" error ?

Pag
asked 7 months ago505 views
1 Answer
0
Accepted Answer

One possible way this can happen is if a Lambda function is run for the first time (we call this a "cold start"); is then stopped for a while; and then is restarted when another event triggers it (a "warm start"). If the time in between the end of the cold start invocation and the warm start is high enough, DynamoDB will have terminated the TCP session that was created during the first invocation. But the Lambda function has no awareness that it was stopped at all - for it, no time passed between the end of the first invocation and the second (the warn start).

The way to prevent this is to ensure that your code re-establishes network sessions on a warm start - either by checking that the session is alive or by handling socket error messages such as this when they occur.

profile pictureAWS
EXPERT
answered 7 months ago
  • Thanks ! We are going to try that on our side and I'll update you if it correct something !

  • After months of monitoring, it seems that it solved the issue. We chased all the clients (dynamodb, eventbridge etc...) and closed them at the send of our lambda execution.

    Hope it helps someone.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions