[SERVER-16971] Error in connecting to mongodb (mongodb-linux-x86_64-2.8.0-rc5) : auth failed, when starting nodejs appserver Created: 21/Jan/15  Updated: 23/Feb/15  Resolved: 23/Feb/15

Status: Closed
Project: Core Server
Component/s: Admin, Security
Affects Version/s: 2.8.0-rc4, 2.8.0-rc5
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Purnima Jayawardena Assignee: Ramon Fernandez Marina
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File SERVER-16971-mongodb-logs.txt     Text File SERVER-16971.txt    
Participants:

 Description   

STEPS:
1. Upgraded mongodb 2.4 --> 2.6 and I am able to start my nodejs app server without any issue.
2. Upgraded the mongodb 2.6 --> 2.8 and set it up to use wiredTiger storage Engine.
3. Created the user in the test db and authenticated it successfully.
4. Tried to start the nodejs app server.

RESULT:
It fails with the following error. But if I remove the authentication part, it starts up fine. I tried with MMAPv1 as well and it still fails with the same error. I posted this issue in stackoverflow but did not get any answer. Since this is public I can only post very limited information. If you need more information, please let me know, I can email to you.

 2015-01-16T18:43:51.115Z <warn> globals.js:45 () MONGO URI = mongodb://myuser:password@localhost:27017/test
 2015-01-16T18:43:51.178Z <error> globals.js:45 () #### Error in connecting to mongodb
 2015-01-16T18:43:51.180Z <error> globals.js:45 () { [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }
 2015-01-16T18:43:51.182Z <error> globals.js:45 () MongoError: auth failed



 Comments   
Comment by Ramon Fernandez Marina [ 23/Feb/15 ]

Thanks for the update redrock, glad to hear you're up and running after upgrading to the latest versions of server and driver.

Comment by Purnima Jayawardena [ 20/Feb/15 ]

I tried it with latest mongodb driver 2.0.16 and auth worked. Also, used latest mongodb-linux-x86_64-3.0.0-rc8.

Comment by Purnima Jayawardena [ 18/Feb/15 ]

Any updates?

Comment by Purnima Jayawardena [ 24/Jan/15 ]

No, each install I deleted the /data directory and created a new /data directory. Also, each time I created a new user, 'theuser' and authenticated that user. In addition, each time, I killed the mongodb server and restarted it again. Therefore, I didn't upgrade any user authorization data.

Comment by Purnima Jayawardena [ 24/Jan/15 ]

I have attached the mongodb logs (see the attachment SERVER-16971-mongodb-logs).

Comment by Ramon Fernandez Marina [ 23/Jan/15 ]

redrock, what we need to see is the logs from mongod, not from your application server. Can you please upload those to see if we can determine why authentication is failing?

Also, did you upgrade your user authorization data when upgrading to 2.6?

Comment by Purnima Jayawardena [ 23/Jan/15 ]

Thanks Ramon for getting back to me.
1. Yes, I had authentication setup in both 2.4 and 2.6.
2. & 3. User creations and full server logs are attached.

User Creation with mongodb 2.4
------------------------------
cogadmin@UBLNX-pj4:~$ mongo
MongoDB shell version: 2.4.9
connecting to: test
> use test
switched to db test
> db.addUser('theuser', 'passw0rd');
{
"user" : "theuser",
"readOnly" : false,
"pwd" : "a7ff4ec639b3681fc2b96eaefffb1b53",
"_id" : ObjectId("54c193f81fb304023ddf2dcc")
}
> db.auth('theuser', 'passw0rd');
1
>

Nodejs app server log (with mongodb 2.4)
----------------------------------------
22 Jan 16:43:19 - [nodemon] v1.2.1
22 Jan 16:43:19 - [nodemon] to restart at any time, enter `rs`
22 Jan 16:43:19 - [nodemon] watching: /home/cogadmin/dctc/CogilityNode/Runtime/migrations/*/
22 Jan 16:43:19 - [nodemon] starting `node /home/cogadmin/dctc/CogilityNode/Runtime/app.js`
Failed to load c++ bson extension, using pure JS version
2015-01-23T00:43:20.448Z <warn> globals.js:45 () Schema Version unspecified
2015-01-23T00:43:20.454Z <warn> globals.js:45 () ENV = undefined
2015-01-23T00:43:20.455Z <warn> globals.js:45 () PROCESS VERSION = v0.10.25
2015-01-23T00:43:20.456Z <warn> globals.js:45 () MONGO URI = mongodb://theuser:passw0rd@localhost:27017/test
2015-01-23T00:43:20.531Z <info> globals.js:45 () 'pearschemamasters' and 'pearschemadetails' already exist. Continue.
2015-01-23T00:43:20.535Z <warn> globals.js:45 () Server running on port 3000
2015-01-23T00:43:20.540Z <warn> globals.js:45 () !!!! There are no PearSchema instances in the database.

User Creation with mongodb 2.6
------------------------------
cogadmin@UBLNX-pj4:~$ mongo
MongoDB shell version: 2.6.7
connecting to: test
> use test;
switched to db test
> db.addUser('theuser', 'passw0rd');
WARNING: The 'addUser' shell helper is DEPRECATED. Please use 'createUser' instead
Successfully added user:

{ "user" : "theuser", "roles" : [ "dbOwner" ] }

> db.auth('theuser', 'passw0rd');
1
>

Nodejs app server log (with mongodb 2.6)
----------------------------------------
22 Jan 17:11:40 - [nodemon] v1.2.1
22 Jan 17:11:40 - [nodemon] to restart at any time, enter `rs`
22 Jan 17:11:40 - [nodemon] watching: /home/cogadmin/dctc/CogilityNode/Runtime/migrations/*/
22 Jan 17:11:40 - [nodemon] starting `node /home/cogadmin/dctc/CogilityNode/Runtime/app.js`
Failed to load c++ bson extension, using pure JS version
2015-01-23T01:11:40.819Z <warn> globals.js:45 () Schema Version unspecified
2015-01-23T01:11:40.825Z <warn> globals.js:45 () ENV = undefined
2015-01-23T01:11:40.826Z <warn> globals.js:45 () PROCESS VERSION = v0.10.25
2015-01-23T01:11:40.827Z <warn> globals.js:45 () MONGO URI = mongodb://theuser:passw0rd@localhost:27017/test
2015-01-23T01:11:40.906Z <info> globals.js:45 () 'pearschemamasters' and 'pearschemadetails' created.
2015-01-23T01:11:40.914Z <warn> globals.js:45 () Server running on port 3000
2015-01-23T01:11:40.967Z <warn> globals.js:45 () !!!! There are no PearSchema instances in the database.

User Creation with mongodb 2.8
-------------------------------------------
cogadmin@UBLNX-pj4:~$ mongo
MongoDB shell version: 2.8.0-rc5
connecting to: test
Server has startup warnings:
2015-01-22T17:59:22.985-0800 I CONTROL [initandlisten]
2015-01-22T17:59:22.985-0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-01-22T17:59:22.986-0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-01-22T17:59:22.986-0800 I CONTROL [initandlisten]
> use test
switched to db test
> db.createUser(

{user: "theuser", pwd: "passw0rd", roles: ["readWrite", "dbAdmin"]}

);
Successfully added user:

{ "user" : "theuser", "roles" : [ "readWrite", "dbAdmin" ] }

> db.auth('theuser', 'passw0rd');
1
>

> db.getUser('theuser');
{
"_id" : "test.theuser",
"user" : "theuser",
"db" : "test",
"roles" : [

{ "role" : "readWrite", "db" : "test" }

,

{ "role" : "dbAdmin", "db" : "test" }

]
}
>

Nodejs app server log (with mongodb 2.8)
-------------------------------------------------------
22 Jan 18:13:11 - [nodemon] v1.2.1
22 Jan 18:13:11 - [nodemon] to restart at any time, enter `rs`
22 Jan 18:13:11 - [nodemon] watching: /home/cogadmin/dctc/CogilityNode/Runtime/migrations/*/
22 Jan 18:13:11 - [nodemon] starting `node /home/cogadmin/dctc/CogilityNode/Runtime/app.js`
Failed to load c++ bson extension, using pure JS version
2015-01-23T02:13:12.082Z <warn> globals.js:45 () Schema Version unspecified
2015-01-23T02:13:12.088Z <warn> globals.js:45 () ENV = undefined
2015-01-23T02:13:12.089Z <warn> globals.js:45 () PROCESS VERSION = v0.10.25
2015-01-23T02:13:12.091Z <warn> globals.js:45 () MONGO URI = mongodb://theuser:passw0rd@localhost:27017/test
2015-01-23T02:13:12.157Z <error> globals.js:45 () #### Error in connecting to mongodb
2015-01-23T02:13:12.159Z <error> globals.js:45 ()

{ [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }

2015-01-23T02:13:12.161Z <error> globals.js:45 () MongoError: auth failed
at Db.wrap (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:1931:11)
at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:686:30
at null.<anonymous> (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:1808:5)
at g (events.js:180:16)
at EventEmitter.emit (events.js:106:17)
at Db._callHandler (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:1506:25)
at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/connection/server.js:478:30
at MongoReply.parseBody (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:127:5)
at null.<anonymous> (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/connection/server.js:435:22)
at EventEmitter.emit (events.js:95:17)

        1. Uncaught error: [ReferenceError: mongoDb is not defined] ReferenceError: mongoDb is not defined
          at /home/cogadmin/dctc/CogilityNode/Runtime/interfaces/pearMongo/mongo.js:33:24
          at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/mongo_client.js:103:20
          at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:2118:11
          at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:700:13
          at null.<anonymous> (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:1808:5)
          at g (events.js:180:16)
          at EventEmitter.emit (events.js:106:17)
          at Db._callHandler (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:1506:25)
          at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/connection/server.js:478:30
          at MongoReply.parseBody (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:127:5)
          2015-01-23T02:13:12.165Z <error> globals.js:45 () #### Uncaught error in master: ReferenceError: mongoDb is not defined
          2015-01-23T02:13:12.167Z <error> globals.js:45 () ReferenceError: mongoDb is not defined
          at /home/cogadmin/dctc/CogilityNode/Runtime/interfaces/pearMongo/mongo.js:33:24
          at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/mongo_client.js:103:20
          at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:2118:11
          at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:700:13
          at null.<anonymous> (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:1808:5)
          at g (events.js:180:16)
          at EventEmitter.emit (events.js:106:17)
          at Db._callHandler (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/db.js:1506:25)
          at /home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/connection/server.js:478:30
          at MongoReply.parseBody (/home/cogadmin/dctc/CogilityNode/Runtime/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:127:5)
Comment by Ramon Fernandez Marina [ 22/Jan/15 ]

redrock, we'll need more information to understand that's going on:

  • Did you have authentication set up in your 2.4 instance?
  • Can you please post details on how you added a user to 2.8?
  • Can you please upload the full server logs going all the way back to the last 2.4 restart?

Thanks,
Ramón.

Generated at Thu Feb 08 03:42:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.