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

Compatibility with version 3.0 of MongoDB #77

Open
fghamsary opened this issue Mar 16, 2015 · 16 comments
Open

Compatibility with version 3.0 of MongoDB #77

fghamsary opened this issue Mar 16, 2015 · 16 comments

Comments

@fghamsary
Copy link

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.

@dselivanov
Copy link
Owner

please, provide more details and reproducible example.

@fghamsary
Copy link
Author

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.

@dselivanov
Copy link
Owner

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
Copy link
Owner

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

@fghamsary
Copy link
Author

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

@dselivanov
Copy link
Owner

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.

@aoyh
Copy link

aoyh commented Apr 27, 2015

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.

@dselivanov
Copy link
Owner

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

@theroys
Copy link

theroys commented Nov 3, 2015

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

@dselivanov
Copy link
Owner

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

@theroys
Copy link

theroys commented Nov 3, 2015

Ok i wlll give it a try within next 3 weeks

@dselivanov
Copy link
Owner

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.

@jeroen
Copy link

jeroen commented Nov 4, 2015

@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
Copy link

jeroen commented Dec 10, 2015

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

@iffmainak
Copy link

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

@jeroen
Copy link

jeroen commented Mar 29, 2018

There is gridfs support now in mongolite.

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

No branches or pull requests

6 participants