我正在尝试从我的 AWS Lambda 发出 http 请求,但它超时了。
我的代码看起来与此类似:
import requests
def lambda_handler(event, context):
print('Im making the request')
request.get('http://www.google.com')
print('I recieved the response')
但是当我测试这个时,我超时了。
输出是
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
所以我知道问题不是找不到请求包,而是它正在运行我的 python 代码。我只是弄清楚为什么它会在该请求上超时。
原文由 user133688 发布,翻译遵循 CC BY-SA 4.0 许可协议
我遇到同样的 超时问题,原因如下。
AWS 文件:
可能在设置 VPC 时出现一些错误。我建议您可以关注此 博客 来构建 NAT。