rmongodb icon indicating copy to clipboard operation
rmongodb copied to clipboard

Compatibility with version 3.0 of MongoDB

Open fghamsary opened this issue 11 years ago • 16 comments

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.

fghamsary avatar Mar 16 '15 16:03 fghamsary

please, provide more details and reproducible example.

dselivanov avatar Mar 16 '15 16:03 dselivanov

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.

fghamsary avatar Mar 16 '15 17:03 fghamsary

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.

dselivanov avatar Mar 17 '15 13:03 dselivanov

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

dselivanov avatar Mar 17 '15 13:03 dselivanov

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 ;)

fghamsary avatar Mar 17 '15 14:03 fghamsary

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.

dselivanov avatar Mar 17 '15 14:03 dselivanov

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:

  1. use an older version of mongoDB, such as mongoDB 2.4
  2. use another R package RMongo. It could be time consuming too as RMongo is dependent on another package rJava which usually requires some set up via shell.

aoyh avatar Apr 27 '15 10:04 aoyh

~~another option is to try mongolite.~~ edit: did't recognize, that it still doesn't not support any authentication

dselivanov avatar Jun 20 '15 10:06 dselivanov

Hi ..anybody still working on this issue..or any pull request regarding this

theroys avatar Nov 03 '15 20:11 theroys

I will review and merge pull, if someone will develop it.

dselivanov avatar Nov 03 '15 20:11 dselivanov

Ok i wlll give it a try within next 3 weeks

theroys avatar Nov 03 '15 20:11 theroys

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 avatar Nov 03 '15 21:11 dselivanov

@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

jeroen avatar Nov 04 '15 09:11 jeroen

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()

jeroen avatar Dec 10 '15 13:12 jeroen

what about access to gridfs .. mongolite donot seem to support that yet

iffmainak avatar Aug 21 '17 00:08 iffmainak

There is gridfs support now in mongolite.

jeroen avatar Mar 29 '18 14:03 jeroen