【问题标题】:How to fix 'connect ETIMEDOUT' while generating authorization token via azure active directory?如何在通过 azure 活动目录生成授权令牌时修复“连接 ETIMEDOUT”?
【发布时间】:2019-06-30 18:10:03
【问题描述】:

实际上,我需要授权令牌,以便我可以将其作为标头传递,以在 node.js 中运行 azure 的“创建管道运行”api。但在这里我再次陷入困境,我得到了“连接 ETIMEDOUT”一次又一次的错误。

var AuthenticationContext = require('adal-node').AuthenticationContext;

var authorityHostUrl = 'https://login.windows.net';

var authorityUrl = authorityHostUrl + '/' + tenant;
var resource = 'https://localhost'; // URI that identifies the resource for which the token is valid.
var tenant = '';
var applicationId = '';
var clientSecret = '';
var context = new AuthenticationContext(authorityUrl);

context.acquireTokenWithClientCredentials(resource, applicationId, clientSecret, function(err, tokenResponse) {
  if (err) {
    console.log('well that didn\'t work: ' + err.stack);
  } else {
    console.log(tokenResponse);
  }
});

它显示以下错误

well that didn't work: Error: tunneling socket could not be established, cause=connect ETIMEDOUT 10.0.0.2:8080
    at ClientRequest.onError (/home/deepti/Desktop/AADL/AADL/node_modules/tunnel-agent/index.js:177:17)
    at Object.onceWrapper (events.js:286:20)
    at ClientRequest.emit (events.js:198:13)
    at Socket.socketErrorListener (_http_client.js:392:9)
    at Socket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

谁能指出错误?

【问题讨论】:

    标签: node.js azure azure-active-directory


    【解决方案1】:

    您的代码中有两个错误。

    1.您应该在authorityUrl之前识别租户参数。

    2.将resource的值替换为https://management.azure.com

    然后它在我这边工作得很好。

    但这些错误不会导致“connect ETIMEDOUT”错误。这似乎是一个代理问题。检查this 是否能解决您的问题。

    【讨论】:

    • 使用 sudo 为我解决了“连接 ETIMEDOUT”错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-11
    • 2019-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-13
    相关资源
    最近更新 更多