Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connecting to replicaSet with username and password #13

Open
stondo opened this issue Mar 1, 2016 · 9 comments
Open

connecting to replicaSet with username and password #13

stondo opened this issue Mar 1, 2016 · 9 comments
Labels

Comments

@stondo
Copy link

stondo commented Mar 1, 2016

I can't figure out how to authenticate on a replicaSet with username and password.
Even looked at the source code and couldn't figure out. Isn't it even supported?
Thanks,

Stefano Tondo

@hiddentao
Copy link
Owner

This should work ok. I use it as follows:

var mongoUrls = [
   'user:[email protected]:32234/dbname',
   'user:[email protected]:17655/dbname'
];

yield Robe.connect(mongoUrls, {
    timeout: 3000
 });

@tixastronauta
Copy link

I also can't authenticate. Even using user:[email protected]:32234/dbname:

Error: Failed to connect to db

@hiddentao
Copy link
Owner

Currently working on Robe v2, which will have updated dependencies. Once that's out this issue might be fixed.

@hiddentao
Copy link
Owner

Just released v2 with updated dependencies. Hopefully this works now.

@llustosa
Copy link

llustosa commented Oct 19, 2016

I still can't connect, don't throw exception and returns an invalid connection.

`"use strict";

var Robe = require('robe');
var mainDB;

try{

mainDB = Robe.connect(['user:pass@server/database']);

} catch (err) {
console.log(err.message);
console.log(err.root);
}

console.log(mainDB);`

console.log returns the following:

Promise {
_bitField: 0,
_fulfillmentHandler0: undefined,
_rejectionHandler0: undefined,
_progressHandler0: undefined,
_promise0: undefined,
_receiver0: undefined,
_settledValue: undefined }

@hiddentao
Copy link
Owner

hiddentao commented Oct 20, 2016

Robe.connect returns a Promise object, so you need to do:

Robe.connect(['user:pass@server/database'])
.then((db) => {
  // db is instance of database
});

@llustosa
Copy link

Thanks!

@llustosa
Copy link

Now I`m trying to do a oplog tailing, but this error is thrown "not authorized for query on local.oplog.rs". Using the same user with another tool, every thing works fine and I can query the oplog collection. Have any idea of what could be happening? The user has a read role on the local database.

`"use strict";

var co = require('co');
var Robe = require('robe');

co(function*() {

var db = yield Robe.connect(['user:pass@server/database']);

var oplog =  yield db.oplog();

yield oplog.start();

console.log(oplog);

oplog.onAny(function(collectionName, operationType, data) {
  console.log(operationType);
});

})
.catch(function(err) {
console.error(err);
});`

@hiddentao
Copy link
Owner

@llustosa Hmm that's tricky. All I can think is that it must be due to monk incorrectly handling auth. Do normal authenticated queries work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants