I wrote a simple mongo test, trying to access mongo server in a vpc. for every run I get : "errorMessage": "*** Task timed out after 3.00 seconds" I have written more handlers in the lambda just to check it.
Thanks.
There are three reasons why retry and timeout issues occur when invoking a Lambda function with an AWS SDK: A remote API is unreachable or takes too long to respond to an API call. The API call doesn't get a response within the socket timeout.
Use the following best practices to properly manage connections between AWS Lambda and Atlas: Define the client to the MongoDB server outside the AWS Lambda handler function. Don't define a new MongoClient object each time you invoke your function.
As weird as it may sound, we finally solved the problem just by changing the callback(null, response)
to context.done(null, response)
. This nonsense took us more time than we would have liked to spend here.
You can find more info about the issue here https://github.com/serverless/serverless/issues/1036
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With