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

Opening too many Mongodb connections #98

Open
vitthalzephyr opened this issue Aug 30, 2021 · 3 comments
Open

Opening too many Mongodb connections #98

vitthalzephyr opened this issue Aug 30, 2021 · 3 comments

Comments

@vitthalzephyr
Copy link

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
Copy link
Author

Hi, any update on this?

@stromyc
Copy link

stromyc commented Dec 1, 2021

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
Copy link

dragos99 commented Aug 9, 2022

The issues section looks dead. Is the project dead?

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

3 participants