NodeJS Sticky Session for Users sharing same IP Address

700 views Asked by At

Our NodeJS (With Sockets and HTTP) project is being used by users (all are working from same office, same network) sharing a same public IP Address. I have put a sticky session implementation which generates an hash based on Public IP Address of the user, then allocates a node worker for it. This stickiness is required for socket.io to work. Since all users are sharing the same public IP Address, hash is always same and hence makes use of only one worker. All the other workers are not being used :-(

Since I am using a very low level NodeJS's net.createServer API with pauseOnConnect option, I am not able to get any other information like headers, cookies to create unique hash for each user.

Questions:

  • Is this stickiness really required ? I am using socket.io-redis to broadcast messages. Not sure if this adapter will help me in handling socket connections and explicitly stickiness need not to be managed. I tried this but doesn't seems to be working.

  • Is it possible to read headers/cookies from a connection object emitted by net.createServer ? I think it is not possible as it doesn't have any implementation of HTTP at this level.

  • Is it possible to make use of http.createServer API and pass request object to worker from the master process. This way I can read headers/cookies and generate a unique hash.

  • Worst case, is it possible to override client's IP Address at the proxy level(using nginx) and set some dummuy unique IP Address for each user.

0

There are 0 answers