-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.questionIssues that look for answers.Issues that look for answers.
Description
Hello! The binding to Local interface option is not working at all.
The case: Arch Linux system with two different ethernet interfaces.
eth0: 192.168.0.173/24
eth1: 192.168.0.182/24
routing table is
default via 192.168.0.1 dev eth0 metric 280
default via 192.168.0.1 dev eth1 metric 281
Every interface has a listening http server on other end with the address: 192.168.0.1
So I'm trying to send a request to each of them with nodejs.
Sample code:
var http = require('http');
var options = {};
options.port = 80;
options.host = "192.168.0.1";
options.path = '/index.html';
options.headers = {'Referer': 'http://' + options.host + ':' + options.port + '/index.html'};
options.localAddress = '192.168.0.182'; //NOT WORKING!! - REQUEST GOING FROM 192.168.0.173!
var creq = http.get(options);
creq.on('response', function (res) {
res.on('data', function (chunk) {
console.log(chunk);
});
});I've even tried creating a socket for that request with new net.Socket({ handle: net._createServerHandle( '192.168.0.182')}); and requests kept going from the wrong address.
There's workaround with 'curl --interface eth1 ...' that works, but it's not a good solution.
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.questionIssues that look for answers.Issues that look for answers.