azat-co / mongoui

MongoDB admin UI server written in Node.js 🎮

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem Connecting to Replica Sets?

Albert-IV opened this issue · comments

Seems that I can't get the config set correctly to connect to a replica set.

I can properly connect to a local non-replica MongoDB database, however when I put in replica set information it fails with not authorized for query on <db_set_in_config>.system.namespaces

Failing replica config:

{
  "database": {
    "default": {
      "host": "<db1_url>,<db2_url>",
      "port": 27017,
      "name": "<db_set>",
      "username": "<username>",
      "password": "<password>"
    }
  }
}

Working Non-Replica Config:

{
  "database": {
    "default": {
      "host": "localhost",
      "port": 27017,
      "name": "some_database",
      "username": "",
      "password": ""
    }
  }
}

Anyone else run into this issue?

I'm thinking this might be an issue with the version of Monk you guys are using (ish). If I replace this line with my hard-coded connection string it will blow up with Error: database names cannot contain the character '.'.

Now, take the following Monk example:

var monk = require('monk');

var db = monk('mongodb://<my_replica_set_connection_string>'),
    User = db.get('users');

User.find({}, function(e, user) {
  if( e ) {
    throw e;
  }

  console.log(user);

  db.close();
  process.exit(0);
});

If I run this using the latest version of Monk (0.9.x), the connection will spit out a user as expected. If I then do npm install monk@0.7.1 inside the same folder and rerun, it will error with the same error, Error: database names cannot contain the character '.'

Now I peered into your source, and I can't find any place where the username and password are utilized in creating a connection string either, which is in #24.

Overall it like to fully support replica sets, we'd need to update to the latest version of Monk, which doesn't have the listDatabases() method any longer.

so what version of Monk do you recommend?

I can't honestly tell you, I've not actually used the library before. It is really up to you, and what additional steps you'd want to take to update the dependencies.

Why don't just use the official mongodb driver?

@danielo515 by now probably we should... but if monk is still working, then there are 3 other priorities before refactors

@droppedoncaprica please see #47 if it solved the issue. closing for now.