Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix the connection.session issue

Tags:

node.js

I'm getting bellow warning when using NODE_ENV=production. What's the fix for this?

Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and obviously only work within a single process.

like image 596
Ganesh Kumar Avatar asked Mar 24 '12 07:03

Ganesh Kumar


People also ask

Why do I keep getting session expired?

If your Internet connection is unstable, periodically disconnecting and reconnecting, it can cause a website session to expire. When the Internet connection is lost the website connection can be terminated, resulting in a session expired message if you try to access any page after the Internet reconnects.

How do I resolve an RDP problem?

To resolve this problem, determine which application is using the same port as RDP. If the port assignment for that application cannot be changed, change the port assigned to RDP by changing the registry. After you change the registry, you must restart the Remote Desktop Services service.


1 Answers

It could be a good idea to use Redis as your session manager. It appears as though you're using either the Express or Connect framework, and for either of them you could use an npm package connect-redis (having installed Redis). With that installed the express code would look something like this:

var express = require ( 'express' )
   , RedisStore = require ( 'connect-redis' ) ( express )
   , sessionStore = new RedisStore ()
   , app = express.createServer ()
   ;

app.configure ( function () {

   app.use ( express.cookieParser () );
   app.use ( express.session ( {
    secret: "keyboard cat", store: sessionStore, key: 'hello.sid'
   } ) );
...
like image 189
Bijou Trouvaille Avatar answered Oct 13 '22 00:10

Bijou Trouvaille