1

I'm using connect-mongo to store session.

Sometimes I'm getting :

MongoError: E11000 duplicate key error collection

I have a relatively large site that uses mongoDB with replications.

I tried to clear the session document and this appear again.

Thanks

Megidd
  • 7,089
  • 6
  • 65
  • 142
Elad Vider
  • 49
  • 5

3 Answers3

2

This may be a known issue happened on sessionstore:

https://github.com/adrai/sessionstore/issues/43

Thomas Choy
  • 321
  • 2
  • 13
0

I had the same problem. Even the uuidv4 workaround didn't work for me. In the end, I moved from 'connect-mongo' to 'connect-mongodb-session'.

You just have to change the configuration store with the original MongoDB URI, and everything works like a charm.

I suspect the 'connect-mongo' is not supported anymore: it has been a while since the last update on github.

Fabio Rotondo
  • 390
  • 2
  • 10
-1

To solve the problem i change the session id that generated from 'express session' by the following code:

var uuidv4 = require('uuid/v4');
app.use(session({
  genid: function(req) {
    return uuidv4() 
  }

}))
Elad Vider
  • 49
  • 5