http.request option "family: 6" doesn't enable request over IPv6 #6440
Closed
Description
- Version: 5.5
- Platform: Ubuntu 14.04.1
- Subsystem: http(s)
Seems like family
option does nothing with actual DNS resolve to ipv6.
Problem is internal server should only use ipv6. So, instead of
https.get({
hostname: 'cloud-api.yandex.net',
path: '/v1/disk/resources?path=/',
family: 6,
port: 443,
protocol: 'https:'
}, (res) => {
console.log(res);
}).on('error', (e) => {
console.log(`Got error: ${e.message}`); // Got error: connect EHOSTUNREACH 213.180.204.127:443
});
i should write
dns.lookup('cloud-api.yandex.net', { family: 6 }, (err, addr, family) => {
https.get({
hostname: addr,
path: '/v1/disk/resources?path=/',
port: 443,
protocol: 'https:',
headers: { host: 'cloud-api.yandex.net' }
}, (res) => {
console.log(res);
}).on('error', (e) => {
console.log(`Got error: ${e.message}`);
});
});
Activity