You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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, }
})
}));
The text was updated successfully, but these errors were encountered:
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.
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, }
})
}));
The text was updated successfully, but these errors were encountered: