尝试运行以下代码时出错。我想连接到一些网址(例如facebook.com)。我收到了错误。
var request = require('request');
request.get({
url: "https://www.facebook.com",
proxy: '35.199.76.79:80',
tunnel:true
}
,function(err,res,body){
if(err) console.log(err)
else console.log(res)
});
错误堆栈:
{ Error: tunneling socket could not be established, cause=connect EINVAL 0.0.0.80:80 - Local (0.0.0.0:0)
at ClientRequest.onError (/home/ujwal/Documents/Projects/proxy-tester/node_modules/tunnel-agent/index.js:177:17)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at Socket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9) code:
'ECONNRESET' }
答案 0 :(得分:0)
如果你在代理后面,我认为你应该首先设置npm代理设置
npm config set proxy 35.199.76.79:80
npm config set https-proxy 35.199.76.79:80