在Node.js脚本中运行请求模块时,连接到远程Linux机器上的URL时出错

时间:2018-09-28 11:54:42

标签: node.js linux remote-server

此代码在我的本地计算机上运行良好,但在另一台计算机上执行时却给出此错误。此外,该URL也可以通过远程计算机访问。

options = {
    url: sampleWatchdogUrl, //set fine
    method: 'GET',
    headers: {
        'Accept': 'application/json',
        'Authorization': `Basic ${authen}`, //set fine 
        'Cache-Control': 'no-cache'
    }
};


request(options, function (err, response, body) {...some code}

我收到此错误:

  

{错误:无法建立隧道套接字,原因=连接   EINVAL 0.0.0.80:80-本地(0.0.0.0:0)       在ClientRequest.onError(/scratch/abhsoni/watchdogApi/node_modules/request/node_modules/tunnel-agent/index.js:177:17)       在Object.onceWrapper(events.js:315:30)       在emitOne上(events.js:116:13)       在ClientRequest.emit(events.js:211:7)       在Socket.socketErrorListener(_http_client.js:387:9)       在emitOne上(events.js:116:13)       在Socket.emit(events.js:211:7)       在emitErrorNT上(internal / streams / destroy.js:66:8)       在_combinedTickCallback(内部/进程/next_tick.js:139:11)       在process._tickDomainCallback(internal / process / next_tick.js:219:9)代码处:“ ECONNRESET”}

如何解决此错误?

0 个答案:

没有答案