Compatibility with version 3.0 of MongoDB
The driver is not compatible with the version 3.0 of MongoDB and it always give the error of Authentication Failed, this is because the default mechanism of authentication have been change in MongoDB 3.0 Please resolve this problem.
please, provide more details and reproducible example.
If you install a MongoDB 3.0 with authentication mechanism. In the configuration if you make _auth = true_ and remove or comment the _noauth=true_ and then re-launch the mongod service, you will have an authentication system by default. in Version 3.0 the default authentication mechanism have been changed to SCRAM-SHA-1 which is different than the last version which were MONGODB-CR. So when we want to connect with rmongodb to the version 3.0 with authentication of mongodb it always give the Authentication Failed error. Of course you should set the admin password, create a new database, create a new user for the database and give proper roles to it. There are two different functions that can do the authentication in rmongodb and both of them give the same error. For example:
mongo <- mongo.create("xx.xx.xx.xx.", username="user", db="db", password="pass")
Authentication failed. (Result) This will give the error: Authentication Failed. And when I take a look at the log of mongod it has been written something like this:
2015-03-16T18:40:15.373+0100 I NETWORK [initandlisten] connection accepted from xx.xx.xx.xx:yyyyy #98 (1 connection now open) 2015-03-16T18:40:15.373+0100 I ACCESS [conn98] authenticate db: db { authenticate: 1, user: "user", nonce: "xxx", key: "xxx" } 2015-03-16T18:40:15.373+0100 I ACCESS [conn98] Failed to authenticate user@db with mechanism MONGODB-CR: AuthenticationFailed MONGODB-CR credentials missing in the user document 2015-03-16T18:40:15.373+0100 I NETWORK [conn98] end connection xx.xx.xx.xx:yyyyy (0 connections now open)
If you use the mongo.create it will work and then using the mongo.authenticate function will give the same result.
thx for reporting. I will check this, but it can be problematic to fix this, because rmongodb is based on old mongo-c-driver-legacy.
If you can help, pull request is very welcome. Note, that branch for new version is rmongodb_2_0: https://github.com/mongosoup/rmongodb/tree/rmongodb_2_0
I know maybe the other ticket which was for upgrading to the new mongo-c-driver will resolve this issue as well. But for now I'm stock :( I'll check the new version, and I'll try my best to be of help ;)
as I know, new mongo-c-driver has totally diffrent API, so the easiest way to upgrade rmongodb to latest mongo-c-driver is to rewrite it from scratch with Rcpp or Rcpp11.
It is true that rmongodb failed to connect mongoDB 3.0. Could be a bit frustrating for novice users, who are new to both rmongodb and mongoDB. 2 solution for users so far:
- use an older version of mongoDB, such as mongoDB 2.4
- use another R package
RMongo. It could be time consuming too asRMongois dependent on another packagerJavawhich usually requires some set up via shell.
~~another option is to try mongolite.~~ edit: did't recognize, that it still doesn't not support any authentication
Hi ..anybody still working on this issue..or any pull request regarding this
I will review and merge pull, if someone will develop it.
Ok i wlll give it a try within next 3 weeks
Also check mongolite project, @jeroenooms did a lot of work porting latest mongo c driver, so I believe it will be more simple to port some functionality of rmongodb to mongolite.
@dselivanov thanks! Mongolite certainly supports authentication, you just need to put your credentials in the mongodb url. Here are some examples: https://gist.github.com/jeroenooms/f9694a48750491c55cbf
The new version of mongolite includes an example with authentication that is run during cmd check to ensure auth works on all platforms:
# Connect to mongolabs
con <- mongo("mtcars", url = "mongodb://readwrite:[email protected]:43942/jeroen_test")
if(con$count() > 0) con$drop()
con$insert(mtcars)
stopifnot(con$count() == nrow(mtcars))
# Query data
mydata <- con$find()
stopifnot(all.equal(mydata, mtcars))
con$drop()
# Automatically disconnect when connection is removed
rm(con)
gc()
what about access to gridfs .. mongolite donot seem to support that yet
There is gridfs support now in mongolite.