【发布时间】:2018-12-07 15:46:58
【问题描述】:
在我的示例项目中,我使用了 Google recaptcha。我需要在后端(Node JS)验证验证码响应。在 NodeJS 中,我使用了请求模块来连接谷歌服务器。但是,我遇到了一些错误,如下所示
Error: connect ECONNREFUSED 172.217.166.100:443
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
节点 JS
formData = {
secret: 'xxxxxx',
response: 'yyyyyy'
}
request.post({
url: "https://www.google.com/recaptcha/api/siteverify",
form: formData
},
function (err, httpResponse, body) {
if (err) throw err;
if (body) {
res.send(body);
}
});
当我尝试为上面的 NodeJS 代码设置代理时,如下所示...
formData = {
secret: 'xxxxxx',
response: 'yyyyyy'
}
request.post({
url: "https://www.google.com/recaptcha/api/siteverify",
form: formData,
proxy: '172.217.166.100' /// Google server IP
},
function (err, httpResponse, body) {
if (err) throw err;
if (body) {
res.send(body);
}
});
我收到了这些错误......
Error: tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:80
at ClientRequest.onError (C:\Users\Desktop\project\Backend\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)
谁能帮我解决这个问题
提前致谢
【问题讨论】:
标签: node.js express npm npm-request