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

MongoDB issues when hosting externally #124

Closed
Dids opened this issue Jan 11, 2015 · 8 comments
Closed

MongoDB issues when hosting externally #124

Dids opened this issue Jan 11, 2015 · 8 comments
Assignees
Milestone

Comments

@Dids
Copy link

Dids commented Jan 11, 2015

Essentially, the MongoDB connector that Countly uses is incompatible with certain MongoDB hosting providers, compose.io in my case.

What ends up happening is that the following connection URLs do not work: mongodb://foo:[email protected]:39530,d2.mongolab.com:39530/helloworld

More on the issue itself here: pilwon/ultimate-seed#128

@Dids
Copy link
Author

Dids commented Jan 11, 2015

Mongoskin is not helping with the issue either, since it's not even maintained anymore.

Even defining replica sets separately in the config result in:
MONGOSKIN:WARN: database or username found in RepliSet server URL, user:[email protected]:port/countly

@ar2rsawseen
Copy link
Member

In most cases this should not be an issue, because Countly provides mongoskin version which has older mongodb driver with it and you should be able to connect to same mongodb by using older url scheme (without mongodb:// protocol), which should look like this:

var countlyConfig = {
    mongodb: "foo:[email protected]:39530/countly?auto_reconnect=true",

Have a test server set up which works with Mongodb 2.6.6

But it most probably won't work with multiple hosts

The other option is to upgrade mongoskin to higher than 1.3.20 (I think the latest one is 1.4.4) that will also upgrade mongodb driver and ability to use new connections urls. I'm now testing on test server and it seems to be working ok, only changes needed to be made is using new url scheme in both countly configs:

var countlyConfig = {
    mongodb: "mongodb://localhost:27017/countly",

And only difference seems to be that SkinClass does not have ObjectID method, so need to add little hack to /api/utils/common.js

after common.db = mongo.db(dbName, dbOptions) need to add

    if(!common.db.ObjectID)
        common.db.ObjectID = mongo.ObjectID;

and in /frontend/express/app.js after var countlyDb = mongo.db(dbName, dbOptions) need to add

if(!countlyDb.ObjectID)
    countlyDb.ObjectID = mongo.ObjectID;

So far it seems to be working and we could switch to new driver in new release

@Dids
Copy link
Author

Dids commented Jan 12, 2015

Thank you for the testing and the patches!

I'm very much looking forward to proper multi-host connection string support, and I'm sure that a lot of others are as well.

@gorkem-cetin gorkem-cetin added this to the Countly 15.02 milestone Jan 12, 2015
@ar2rsawseen
Copy link
Member

Hmm, but using replSets also seem to work, if you do not use db name in each server like:

mongodb: {
        replSetServers : [
            'd1.mongolab.com:39530',
            'd2.mongolab.com:39530'
        ],
        db: "countly",
        max_pool_size: 1000
    },

@Dids
Copy link
Author

Dids commented Jan 12, 2015

That's what I tried in the second comment, but I additionally had to add a username & password. I tried setting the database name with the URL and without it in the URL but in the db variable instead, neither worked and produced the warning in comment number 2.

@Dids
Copy link
Author

Dids commented Jan 28, 2015

I'm trying to use Compose.io again as the DB host. What roles does Countly require from the database user?
Compose.io gives readWrite@db, but not dbAdmin@db, and I'm seeing these in the MongoDB log file:

assertion 13 not authorized for query on countly.members ns:countly.members query:{ api_key: "" }

@Dids
Copy link
Author

Dids commented Jan 28, 2015

Yeah, it's not a permission issue, it's an issue with Countly/MongoDB driver.
It would seem like there's no username & password support for when using replSetServers.

@ar2rsawseen
Copy link
Member

New MongoDB driver (including new connection string format) is used in b657d76

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

No branches or pull requests

3 participants