【发布时间】:2017-06-06 07:53:17
【问题描述】:
我正在尝试在我的节点服务器中进行 http 调用(我正在尝试的 URL 是 skackexchange 公共 url),下面是代码
httpsServer.js
var https = require('https');
function httpsRequest() {
var options = {
hostname: 'api.stackexchange.com',
path: '/2.2/answers',
method: 'GET'
};
var req = https.request(options, (res) => {
res.on('data', function (data) {
console.dir(data);
});
req.end();
});
req.on('error', function (e) {
console.error(e);
});
}
httpsRequest();
我在我的控制台中做了node httpsServer
但我收到以下错误。
Error:
{ Error: connect ECONNREFUSED xxx.xxx.xxx.xx:443
at Object.exports._errnoException (util.js:1050:11)
at exports._exceptionWithHostPort (util.js:1073:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1093:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: 'xxx.xxx.xxx.xx',
port: 443 }
注意:我在代理服务器后面。
我做错了什么?如果是因为我在代理后面,有没有办法让它工作?
【问题讨论】:
-
尝试设置
mysql.conf,评论skip-networking。该错误只是 MySQL 服务器的错误配置。否则你可以试试stackoverflow.com/a/19793797/7707749这个答案,如果它仍然不起作用。 -
在我的情况下,套接字只是在一段时间后挂断。
-
来这里的人可能还想看看我的评论:stackoverflow.com/questions/64828363/…
标签: node.js econnrefused