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

Add support for Mongos topology #241

Closed
kapetan opened this issue Aug 13, 2015 · 7 comments
Closed

Add support for Mongos topology #241

kapetan opened this issue Aug 13, 2015 · 7 comments

Comments

@kapetan
Copy link
Contributor

kapetan commented Aug 13, 2015

mongodb-core also supports the Mongos topology, which is not exposed by mongojs.

Maybe lib/get-topology.js should also be a able to return an Mongos instance.

@saintedlama
Copy link
Collaborator

Implemented a very experimental version in branch saintedlama/mongos https://github.com/mafintosh/mongojs/tree/saintedlama/mongos would be awesome if you could give that version a try (= alpha test)

@kapetan
Copy link
Contributor Author

kapetan commented Aug 14, 2015

That was fast. I gave it a try, and I can connect and retrieve documents, but it throws a type error when trying to close the database.

The script I used.

var mongojs = require('mongojs');

var connection = '...';
var options = {
    mongos: true,
    ssl: true,
    sslValidate: false,
    rejectUnauthorized: false,
    authMechanism: 'ScramSHA1'
};

var db = mongojs(connection, ['appUsers'], options);

db.appUsers.findOne({}, function(err, user) {
    console.log(user); // Returns the user
    db.close(); // Call to close throws a TypeError
});

The stack of the error.

/private/tmp/mj/node_modules/mongojs/node_modules/mongodb-core/lib/cursor.js:247
      throw err;
            ^
TypeError: Object [object Object] has no method 'destroy'
    at /private/tmp/mj/node_modules/mongojs/lib/database.js:66:12
    at apply (/private/tmp/mj/node_modules/mongojs/node_modules/thunky/index.js:16:28)
    at null._getServer (/private/tmp/mj/node_modules/mongojs/node_modules/thunky/index.js:27:3)
    at Database.close (/private/tmp/mj/node_modules/mongojs/lib/database.js:64:8)
    at /private/tmp/mj/index.js:15:5
    at /private/tmp/mj/node_modules/mongojs/lib/collection.js:51:5
    at handleCallback (/private/tmp/mj/node_modules/mongojs/node_modules/mongodb-core/lib/cursor.js:244:5)
    at nextFunction (/private/tmp/mj/node_modules/mongojs/node_modules/mongodb-core/lib/cursor.js:739:5)
    at /private/tmp/mj/node_modules/mongojs/node_modules/mongodb-core/lib/cursor.js:664:7
    at queryCallback (/private/tmp/mj/node_modules/mongojs/node_modules/mongodb-core/lib/cursor.js:321:5)

@saintedlama
Copy link
Collaborator

Could you give it a try with a non auth mongos connection. I guess this could narrow issue issue #224 - I suspect the error to arise only in auth environments

@saintedlama
Copy link
Collaborator

Any update?

@kapetan
Copy link
Contributor Author

kapetan commented Aug 19, 2015

Sorry I didn't answer sooner, but I didn't have a mongos setup without authentication running, and I didn't have the time to try to set it up locally. I'll see if I can do it one of these days.

@saintedlama
Copy link
Collaborator

👍 great thanks for your help

@saintedlama
Copy link
Collaborator

Should be fixed in version 2.0 (released just some seconds ago)

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

2 participants