Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
862 views
in Technique[技术] by (71.8m points)

amazon web services - Python request in AWS Lambda timing out

I'm trying to make a http request from my AWS Lambda but it times out.

My code looks similiar to this:

import requests

def lambda_handler(event, context):
    print('Im making the request')
    request.get('http://www.google.com')
    print('I recieved the response')

But when I test this, I get a timeout.

The output is

Im making the request
END RequestId: id
REPORT RequestId: id    Duration: 15003.25 ms   Billed Duration: 15000 ms   Memory Size: 128 MB Max Memory Used: 18 MB  
2016-04-08T20:33:49.951Z id Task timed out after 15.00 seconds

So I know the issue isn't it not finding the request package, and it's running my python code. I just figure out why it times out on that request.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The default value for timeout in Lambda is 3 seconds = 3000 microseconds. Go to Advanced settings and add 5 min. This could be the only issue, if the timeout happens exactly at 3 seconds. All other errors would take something more or less than that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...