How to fix RequestError: Error: connect ETIMEDOUT while running Mocha JS/NodeJS test from behind proxy

How to fix RequestError: Error: connect ETIMEDOUT while running Mocha JS/NodeJS test from behind proxy

我在尝试 运行 Mocha JS 测试用例时遇到以下错误,运行s npm request-promise 调用 REST 服务。我能够通过 ARC 客户端连接到 REST URI 端点,但在 运行 通过组织的代理

连接时失败并出现以下错误
     RequestError: Error: connect ETIMEDOUT SERVER_IP:SERVER_PORT
  at new RequestError (<Some_Path>\errors.js:14:15)
  at Request.plumbing.callback (<Some_Path>\plumbing.js:87:29)
  at Request.RP$callback [as _callback] (<Some_Path>\plumbing.js:46:31)
  at self.callback (<Some_Path>\request.js:188:22)
  at Request.onRequestError (<Some_Path>\request\request.js:884:8)
  at TLSSocket.socketErrorListener (_http_client.js:309:9)
  at emitErrorNT (net.js:1277:8)
  at _combinedTickCallback (internal/process/next_tick.js:80:11)
  at process._tickCallback (internal/process/next_tick.js:104:9)

我通过在 request-promise 选项中添加以下内容解决了这个问题-

proxy:'http://PROXY_SERVER_IP:PORT#'

希望对您有所帮助。

干杯, 库纳尔

这对我有用

var request = require('request-promise').defaults({ 代理:'http://username:password@host:port', 严格的 SSL:假 });