【问题标题】:Nodejs micro service timed out while hitting to other micro serviceNodejs微服务在访问其他微服务时超时
【发布时间】:2018-03-05 14:08:33
【问题描述】:

我在 ec2 实例上托管微服务。 当我们在开发环境中运行它时,一切正常。但是当我在 https (prod) 环境中运行它时。其中一项服务无法访问另一项服务,出现以下错误:

0|auth_mgr | error: Error Authenticating User:  Error: connect ETIMEDOUT 52.7.165.49:3001
0|auth_mgr |     at Object._errnoException (util.js:1003:13)
0|auth_mgr |     at _exceptionWithHostPort (util.js:1024:20)
0|auth_mgr |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)

当我从本地机器上打邮递员时,它可以工作:

var userURL   = configuration.url.user + '/pool/' + userName;
    request({
        url: userURL,
        method: "GET",
        json: true,
        headers: {
            "content-type": "application/json",
        }
    }, function (error, response, body) {
        if (!error && response.statusCode === 200) {
            callback(null, body);
        }
    else {
        if (!error) {
            var lookupError = new Error("Failed looking up user pool: " + response.body.Error);
            callback(lookupError, response);
        }
        else {
            callback(error, response)
        }
    }
});

网址例如。 https://abc.xyz.com:3001/user/pool/john@doe.com

【问题讨论】:

  • 您是否能够从 Postman 访问 ec2 API,它是否返回与上述相同的错误?我假设您显示的错误来自终端
  • @Stretch0 是的,我可以通过 Postman 从我的本地计算机上点击它,它工作正常。它没有给我上述错误。

标签: javascript node.js amazon-web-services amazon-ec2


【解决方案1】:

现在我已经添加了安全组来打开“任何地方”的端口。这对我有用。

【讨论】:

    猜你喜欢
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-13
    • 2017-12-31
    • 2016-03-27
    • 2017-08-31
    • 2017-03-31
    相关资源
    最近更新 更多