-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
Affects Version/s: 2.0.33
-
Component/s: None
-
Environment:CentOS 6.6
node v0.10.38
mongodb db version v3.0.3, git version: b40106b36eecd1b4407eb1ad1af6bc60593c6105, OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
-
Empty show more show less
Given the connection URL mongodb://127.0.0.1:27017,127.0.0.1:27016/thing where 127.0.0.1:2701[6,7] are mongos instances, after successfully connecting, when attempting to authenticate, the callback of db.authenticate is never received or a MongoError: could not authenticate error is thrown (both results have been witnessed).
Stack trace of thrown error:
/tmp/mdblogin/node_modules/mongodb/lib/utils.js:97 process.nextTick(function() { throw err; }); ^ MongoError: could not authenticate at /tmp/mdblogin/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:1053:28 at ScramSHA1.auth (/tmp/mdblogin/node_modules/mongodb/node_modules/mongodb-core/lib/auth/scram.js:108:25) at Server.auth (/tmp/mdblogin/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:1058:40) at Mongos.auth (/tmp/mdblogin/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/mongos.js:620:17) at Mongos.auth (/tmp/mdblogin/node_modules/mongodb/lib/mongos.js:364:22) at Db.authenticate (/tmp/mdblogin/node_modules/mongodb/lib/db.js:1115:21) at /tmp/mdblogin/index.js:11:5 at /tmp/mdblogin/node_modules/mongodb/lib/mongo_client.js:403:11 at process._tickCallback (node.js:448:13)
When using a single mongos in the connection string, connecting and authenticating is successful and quick, i.e. mongodb://127.0.0.1:27017/thing.
I can reproduce this with the following service topology:
- mongod shardsvr 127.0.0.1:27018 (mongod.conf)
- mongod configsvr 127.0.0.1:27019 (mongoc.conf)
- mongos 127.0.0.1:27017 (mongos0.conf)
- mongos 127.0.0.1:27016 (mongos1.conf)
They are started with the following:
#!/bin/bash mongod -f mongod.conf; mongod -f mongoc.conf; sleep 5; mongos -f mongos0.conf; mongos -f mongos1.conf;
Setup notes:
- mongod shardsvr is the only shard sh.addShard('127.0.0.1:27018');
- running in auth mode with default SCRAM-SHA-1 auth method
The following users exist (root is on configsvr/mongos and mongod; username is on thing database only):
use admin; db.createUser({ user: 'root', pwd: 'root', roles: ['root','restore'] }); use thing; db.createUser({ user: 'username', pwd: 'password', roles: [ {role:'readWrite',db:'thing'}, {role:'dbAdmin',db:'thing'}, ] });
I have attached a script test.js that illustrates this behavior.
This type of connection string worked successfully in driver version 1.4. I have not tested on anything other than CentOS.
AFAIK, there is no workaround. I'm not sure how to add more than one mongos to the connection string in order to satisfy redundancy and resiliancy requirements.