-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Using pm2 with session management #286
Comments
There are a lot of ways to solve this.
I'd really recommend to store sessions in the database. It is how it supposed to work. Self-contained tokens is also an interesting idea. You encrypt session information inside your session token, and sign it to prevent tampering. It can be decrypted on every node provided they have a shared secret. |
I solved this using option 2., though using memcached instead of redis. Server I use had memcached installed out of the box. Thanks! |
Semi-offtopic and semi-non-offtopic. I'm quite new to clustering. So I was wondering that is there any ways to use this manner when using sockets.io? I mean in process that is used in clustered mode with pm2? By default handshakes between clustered processes and and clients would happen by random in clustered mode using sockets.io, am I right? There is a same analogy with socket.io handshakes and i.e. login http-sessions? |
Are there any examples using pm2 with Redis? Redis seems to work until I start pm2 for more than one process. That is, sessions don't seem to be shared between processes. Any help appreciated. |
I use session based authentication using Passport.js. Web I run it as a single threaded process, everything works as expected. But when I run it using pm2 cluster-mode the troubles begin. Requests are being handled in different cores time to time so sessions die occasionally. Can this problem be prevented in any other way than for example using Redis to store sessions?
Any pm2 built in way to do this?
The text was updated successfully, but these errors were encountered: