0

From an AWS Lambda function, using Python code, I'm trying to make a request.get("https://linkedin.com"), and sometimes I receive a timeout from the Lambda, and other times the following error message: [ERROR] ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')).

The Lambda security group has all outbound traffic open, and I have tested a curl from another machine in the same subnet as the Lambda (request.get method is not working for few specific websites in AWS Lambda Python shell), and it works perfectly. What could be happening?

3
  • 1
    Have you increased timeout in lambda Function configuration? As default timeout is 3secs, You have to increase as per your functionality. Maximum timeout Limit is 15min Commented Dec 11, 2023 at 10:21
  • similar question asked before in stackoverflow maybe this can help u, stackoverflow.com/a/31822414/10929840 Commented Dec 11, 2023 at 10:31
  • When I try to make a requests.post to log in to LinkedIn, I also get a timeout. How do I log in then? Commented Dec 11, 2023 at 12:17

1 Answer 1

1

The Lambda security group has all outbound traffic open,

So you have it deployed to a VPC

and I have tested a curl from another machine in the same subnet as the Lambda

The machine you tested curl from probably has a public IP address. A Lambda function in a VPC never gets a public IP address. To provide a Lambda function in a VPC access to a service on the Internet, you have to add a NAT Gateway to your VPC, configure some private subnets with a route to that NAT Gateway, and configure the Lambda function to only run in those private subnets.

If your Lambda function doesn't actually need to access anything inside the VPC, then it is a much better option to simply configure the Lambda function to run without a VPC.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.