[英]I am not able to call rest api which is in another container running at localhost:9090, using localstack 12.5 lambda (running at 4566 port)
dummy.py file for lambda hanlder用于 lambda 处理程序的 dummy.py 文件
import sys
import requests
def handler(event, context):
print("Inside handler")
x = requests.get('http://localhost:9090/ping')
print(x.status_code)
return str(x.content)
In handler when i am calling get api which is in another container i am getting connection refused error.在处理程序中,当我调用另一个容器中的 get api 时,我收到连接被拒绝的错误。
Error: "ConnectionError","errorMessage":"HTTPConnectionPool(host='localhost', port=9090): Max retries exceeded with url: Caused by NewConnectionError('\
错误:"ConnectionError","errorMessage":"HTTPConnectionPool(host='localhost', port=9090): Max retries exceeded with url: Caused by NewConnectionError('\
However with postman I am able to hit http://localhost:9090/ping API但是通过邮递员,我可以访问 http://localhost:9090/ping API
Also If I replace x = requests.get('https://w3schools.com') then I am getting 200 .另外,如果我替换 x = requests.get('https://w3schools.com') 那么我得到 200 。
The issue has been resolved by adding below env variable in localstack该问题已通过在 localstack 中添加以下 env 变量解决
LAMBDA_DOCKER_NETWORK="host" LAMBDA_DOCKER_NETWORK="主机"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.