Hasura操作处理程序不存在(名称或服务未知)

3
我在 Docker 容器中运行了 Hasura 实例,并且直接在机器上运行了使用 NodeJS/Express 编写的操作处理程序 API。
当我在本地测试一切正常(macOS M1),但是当我在服务器上复制相同的设置(Ubuntu 20.04)时,它会返回一个操作处理程序不存在的错误。
所有其他查询和变异都能正常工作,只有操作会返回此错误。
您可以看到 Hasura 和 NodeJS 应用程序都在运行。 Hasura Docker 容器 本地主机 API 调用 在本地开发中,我的操作处理程序基础 URL 是:

http://host.docker.internal:5000/api

"并且它运行得很好。我也尝试了 http://localhost:5000/api"

http://127.0.0.1:5000/api

这是 Hasura 动作调用返回的确切错误。
{
"errors": [
    {
        "extensions": {
            "internal": {
                "error": {
                    "type": "http_exception",
                    "message": "ConnectionFailure Network.Socket.getAddrInfo (called with preferred socket type/protocol: AddrInfo {addrFlags = [], addrFamily = AF_UNSPEC, addrSocketType = Stream, addrProtocol = 0, addrAddress = 0.0.0.0:0, addrCanonName = Nothing}, host name: Just \"host.docker.internal\", service name: Just \"5000\"): does not exist (Name or service not known)"
                },
                "response": null,
                "request": {
                    "body": {
                        "session_variables": {
                            "x-hasura-role": "public"
                        },
                        "input": {
                            "email": "",
                            "password": ""
                        },
                        "action": {
                            "name": "login"
                        }
                    },
                    "url": "http://host.docker.internal:5000/api/auth/login",
                    "headers": []
                }
            },
            "path": "$",
            "code": "unexpected"
        },
        "message": "http exception when calling webhook"
    }
]

}

1个回答

2
如果有人遇到同样的问题,这是我解决它的方法。
将以下内容添加到docker-compose.yml文件中。
    extra_hosts:
    - "host.docker.internal:host-gateway"

允许防火墙中的端口80805000

 sudo ufw allow 8080 
 sudo ufw allow 5000

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接