mongodb-js / connect-mongodb-session

Lightweight MongoDB-backed session store for Connect and Express
Apache License 2.0
175 stars 35 forks source link

Opening too many Mongodb connections #98

Open vitthalzephyr opened 3 years ago

vitthalzephyr commented 3 years ago

Hi, I have recently migrated from connect-mongo to connect-mongodb-session(v2.4.1) expecting it to be lightweight and better. However I am observing that my number of connections to MongoDb (hosted on Atlas cluster M0) is been significantly increasing. I have 6 express servers and apart from using MongoStore, I also use mongoose for database queries. For each such connection, I have setup poolSize to be 10 and SocketTimeOutMS to be 10000. However I am observing my number of connections fluctuating heavily and sometimes going to 500! When I bring my express server down, I see the number of connections reduce to zero. Also I understand there is no way (unlike connect-mongo) to reuse the mongoose connection with connect-mongodb-session. Can you please help with solution? My express server code for session-store is below: app.use(session({ secret: process.env.SESSION_SECRET, saveUninitialized: false, resave: false, rolling: false, name: process.env.COOKIENAME, cookie: sessionCookieOptions, store: new MongoStore({ uri: process.env.INRMONGODB, ttl: 2000, autoRemove: 'interval', autoRemoveInterval: 20, // In minutes hash: { salt: process.env.SALTSECRET, algorithm: 'sha1' }, connectionOptions: {useNewUrlParser: true, useUnifiedTopology: true, poolSize: 10, socketTimeoutMS: 10000, } }) }));

vitthalzephyr commented 3 years ago

Hi, any update on this?

stromyc commented 2 years ago

I'm seeing the same problem. In fact, just leaving a browser open to a webpage has resulted in over 1400 sessions being created in just a 12 hour period.
I switched to connect-mongo and it is showing normal behavior with regards to session stores in mongodb.

dragos99 commented 2 years ago

The issues section looks dead. Is the project dead?