Reputation: 2470
I have written a program that exercises the REST API of an embedded device that my team is developing. The code that issues the https requests looks like this:
var options = {
hostname: hostAddress,
port: hostPort,
path: path,
method: methodName,
headers: {
"Content-Type": "application/json",
"Content-Length": post_data.length
}
};
// Request and callback
var request = https.request(
options,
function onResponse( response ) {
// response code happens in here ...
}
);
This code works just fine when hostAddress
is an IPv4 address, e.g. "192.168.1.13". But we've recently added IPv6 support onto the embedded device and that needs to be tested as well. However, the same code above does not work when the hostAddress
is an IPv6 address.
The documentation for https.request() [here: https://nodejs.org/api/https.html ] doesn't say anything about IPv6. I have tried using each of the following values for the hostAddress
, but without success.
hostAddress = "fe80::9eb6:54ff:fe90:8b70%eth0";
hostAddress = "[fe80::9eb6:54ff:fe90:8b70%eth0]";
hostAddress = "fe80::9eb6:54ff:fe90:8b70";
hostAddress = "[fe80::9eb6:54ff:fe90:8b70]";
I know the IPv6 address is correct -- I copied and pasted it from an ifconfig call on the embedded system host.
Can anyone tell me what I'm missing here?
Upvotes: 2
Views: 2247
Reputation: 72875
Node version 0.12 doesn't support IPv6 on DNS binding, and since request
utilizes that, it also won't work.
Per this thread, it's scheduled for implementation in v0.13.
Update
As of 2015, this appears to now be implemented in the main nodejs/node project (the re-amalgamation of Node.js and io.js).
http = require('http');
server = http.createServer();
server.listen(9000, '::');
Upvotes: 4