A
A
Alexey Yarkov2016-05-24 21:33:53
MongoDB
Alexey Yarkov, 2016-05-24 21:33:53

How to fix Mongo error?

We have an error:

{ MongoError: Mod on _id not allowed
    at Function.MongoError.create (/root/projects/datakeeper/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:31:11)
    at toError (/root/projects/datakeeper/node_modules/mongoose/node_modules/mongodb/lib/utils.js:114:22)
    at /root/projects/datakeeper/node_modules/mongoose/node_modules/mongodb/lib/collection.js:1007:60
    at getLastErrorCallback (/root/projects/datakeeper/node_modules/mongoose/node_modules/mongodb-core/lib/wireprotocol/2_4_support.js:462:20)
    at Callbacks.emit (/root/projects/datakeeper/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js:119:3)
    at .messageHandler (/root/projects/datakeeper/node_modules/mongoose/node_modules/mongodb-core/lib/topologies/server.js:358:23)
    at Socket.<anonymous> (/root/projects/datakeeper/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:292:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:542:20)
  name: 'MongoError',
  message: 'Mod on _id not allowed',
  driver: true,
  ok: 1,
  n: 0,
  code: 10148,
  errmsg: 'Mod on _id not allowed',
  writeConcernError: { code: 10148, errmsg: 'Mod on _id not allowed' } }

The algorithm of actions is as follows:
1. Enter the login and password and click "Login"
2. There is a request: api/v1/login
3. On the server, upon successful authorization, we write user data to the session and respond with JSON
4. The browser receives a response with session data for Angular (everything is OK)
5. After receiving a response with a code of 200, the state is changed to domen.ru/user/profile , while the session is checked: api/v1/user/session/valid
And now the 401 code comes and the error "Session Expired".
For sessions I use this:
var session = require('express-session');
var MongoStore = require('mongoose-session')(mongoose);

app.use(session({
  genid: function(req) {
    return uuid.v4();
  },
  saveUninitialized: false,
  resave: true,
  cookie: { 
    name: config.get('session_cookie_name'),
    maxAge:  (60*60*1000*24), 
    secure: true
  } , 
  key: config.get('session_cookie_name'),
  secret: config.get('session_cookie_secret'),
  proxy: true,
  store: MongoStore
}));

Since the validation of the session is that it is checked whether it exists at all)), I dare to assume that it is not created at all. The sessions collection is empty.
Problems started after moving to VDS. On local and c9.io everything works.
MongoDB shell version: 2.4.9
UPD#1: If it matters, Node.js is preceded by Nginx and SSL enabled

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2016-05-25
@yarkov

Everything is simple! Updated to 3.2.6

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question