N
N
newaitix2017-07-09 20:53:45
MongoDB
newaitix, 2017-07-09 20:53:45

The connection is not closed. What am I doing wrong?

var session = require('express-session'); 
var MongoStore = require('connect-mongo')(session);
var mongoose = require('mongoose');
var mongoose_store = new MongoStore({mongooseConnection: mongoose.connection});

app.use(session({
  secret:conf.get('session:secret'),
  key:conf.get('session:key'),
  cookie:conf.get('session:cookie'),
  saveUninitialized:false,
  resave:false,
  store: new MongoStore({ mongooseConnection: mongoose.connection })
}));

If you remove the store property, then the site is loaded normally; if you leave it, the connection is suspended and the site is not loaded to the end. Why ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
4
4X_Pro, 2017-07-09
@XXXXPro

Unfortunately, I don’t understand node.js, but the question arose: why are you creating two MongoStore objects? One at the start, one at the store: new MongoStore? Maybe there you need to use the already created one?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question