Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection.remoteAddress is undefined #7

Closed
DefrenneD opened this issue Dec 4, 2014 · 9 comments
Closed

connection.remoteAddress is undefined #7

DefrenneD opened this issue Dec 4, 2014 · 9 comments

Comments

@DefrenneD
Copy link

Hi everybody,

I'm using nginx as a reverse-proxy and connection.remoteAddress is undefined.

var server = net.createServer(function(connection) {
...
connection.remoteAddress //undefined
...
}).listen('/tmp/node.sock');

Do you have any ideas how I could get the IP ?

When i'm testing without nginx everything is fine.

@barisusakli
Copy link

See this thread indutny/sticky-session#6 I don't think there is a simple solution yet. I ended up dropping node cluster and spawning workers on different ports and load balancing with nginx.

@elad
Copy link
Owner

elad commented Dec 5, 2014

Is the problem here that the source address is set in a header by nginx which requires reading data before being able to tell which worker to pass the connection to?

@barisusakli
Copy link

@elad yes exactly.

@wzrdtales
Copy link

Pull request fixing this issue is open indutny/sticky-session#17, you could look into this to fix your problems.

@elad
Copy link
Owner

elad commented Dec 15, 2014

I don't like the idea of peeking into a packet and parsing it... :/

@wzrdtales
Copy link

@elad Then make a better suggestion...
I tried several other ways, but the only way it worked was getting it directly on the TCP Layer and putting it right back there.

At least this is exactly the same thing you would do if you would let make NGINX the balancing or HAProxy instead. It processes all packets, manipulating them and then sending them to node. But you don't send it over the Network Layer again, you just push it back to the read queue.

If you really have an Idea that works, I would be absolutely pleasured if you would tell me. As I already pointed out in the pull request, I don't have a problem with getting a packet and parsing it myself. There is nothing wrong with this, but I have a problem with relying on a function which behavior changes regurlarly often. And if there is a possibility that this functionality can be archived easier, this would be great.

"If there is any other way to accomplish this, I would be pleased if you would tell me :)
Accessing this component is not really beautiful, as it changes often and is not stable and/or backward compatible. That is also the reason why this fix only works in the rnage of 0.9.7 to 0.11."

@elad
Copy link
Owner

elad commented Dec 15, 2014

I don't have a better idea at the moment. Once I have some free time to look into it I hope I will, though. :)

@elad
Copy link
Owner

elad commented Apr 6, 2016

Closing for the same reason as #15.

@davidolen
Copy link

@barisusakli

Just interested, when you were "dropping node cluster and spawning workers on different ports", did you start each worker process using a separate command "node app.js"? Or did you use another module to create and manage the worker processes? Also, what is the performance (and reliability)?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants