【发布时间】:2015-08-21 00:15:46
【问题描述】:
it always gives :
Error: getaddrinfo ENOTFOUND <hostname without http or https>
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
STATUS: undefined
我的代码如下:-
var Http = require('https');
var str = "";
var options = {
hostname: '<host name without http or https>',
path: '<path>',
method: 'POST',
headers: {
'Content-Type': 'application/json;charset:utf-8',
'Content-Length': payload.length,
'User-Agent': 'Node.js/0.12.7',
'Proxy-Connections': 'keep-alive'
}
};
var req = Http.request(options, function(res) {
res.setEncoding('utf-8');
res.on('data', function(response) {
str += response;
});
res.on('end', function() {
return exits.success(str);
});
});
req.on('error', function(e) {
console.log('STATUS: ' + e.statusCode);
exits.error('problem with request: ' + e.message);
});
req.write(payload);
req.end();
我已经尝试过以下操作:-
- 设置代理和 https-proxy
- 从主机名中删除 http 或 https
请帮我解决这个问题。
【问题讨论】:
-
options对象中需要填写实际的hostname和path。 -
感谢您的回复,但我已经尝试过了,但没有任何帮助。
标签: node.js https proxy request