-1

Following is the console session...

C:\Users\xxx>vmc tunnel myMongoDB
Getting tunnel connection info: OK

Service connection info:
  username : uuuu
  password : pppp
  name     : db
  url      : mongodb://uuuu:pppp@172.30.xx.xx:25200/db

Starting tunnel to myMongoDB on port 10000.
1: none
2: mongo
3: mongodump
4: mongorestore
Which client would you like to start?: 2
Launching 'mongo --host localhost --port 10000 -u uuuu -p pppp db'

MongoDB shell version: 2.0.6
connecting to: localhost:10000/db
> db.serverStatus()
{ "errmsg" : "need to login", "ok" : 0 }
>

Which credentials should I use to login (assuming should use db.auth) to get rid of the error "{ "errmsg" : "need to login", "ok" : 0 }".

When I run the same in micro CF on my machine it works ok and gives me the expected output.

P.S. I'm trying this to get to know the current connections on my application, written in node.js. Trying to debug some issues with connections to the DB. If there is any other alternative that I can use please suggest that as well.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ajay
  • 68
  • 6
  • Does anyone have any suggestions for this issue? – Ajay Sep 11 '12 at 19:19
  • I would think it would be the admin user for that server (user stored in the admin server). So use the admin db and then do db.auth. – christkv Sep 12 '12 at 08:00
  • @christkv I tried using "admin" db but it shows the following error... C:\Users\am185011>mongo --host localhost --port 10000 -u uuuu -p pppp admin MongoDB shell version: 2.0.6 connecting to: localhost:10000/admin Thu Sep 13 10:14:30 uncaught exception: login failed exception: login failed Please note I had also got an "admin" user when I did "show users" when logged in to "db" database. So I tried the above command with that user too, but the same end result. – Ajay Sep 13 '12 at 05:04
  • @christkv Another approach I tried was to do "use admin" after logging into "db" database. (no luck) > use admin switched to db admin > show collections Thu Sep 13 10:07:47 uncaught exception: error: { "$err" : "unauthorized db:admin lock type:-1 client:172.30.49.241", "code" : 10057 } > db.serverStatus(); { "errmsg" : "need to login", "ok" : 0 } > show users Thu Sep 13 10:08:37 uncaught exception: error: { "$err" : "unauthorized db:admin lock type:-1 client:172.30.49.241", "code" : 10057 } – Ajay Sep 13 '12 at 05:05
  • @christkv Please let me know if I have not understood your comment and am doing something incorrectly. – Ajay Sep 13 '12 at 05:05

1 Answers1

1

this should work! Not sure why your tunnel isn't connecting, my immediate suggestion is to try another instance of MongoDB and see if the same error occurs.

If you are trying to inspect the bound services on you node.js app you should be able to inspect them in the VCAP_SERVICES environment variable. For example;

var http = require('http');
var util = require('util');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write(util.inspect(process.env.VCAP_SERVICES));
  res.write("\n\n************\n\n");
  res.end(util.inspect(req.headers));

}).listen(3000);

This code is currently running at http://node-headers.cloudfoundry.com/ to serve as an example. However, mongodb connections for node.js applications should automatically configure to the bound service. If this does not work for you, then please do let me know.

Dan Higham
  • 3,974
  • 16
  • 15
  • Hi @dan-higham. Thanks for your response. Wanted to add some clarifications... 1. My connection with the tunnel is fine. I know that since I can do other operations using the connections like db.myCollection.find(xx). 2. I'm not trying to debug service connectivity. I'm trying to debug the number of connections that are opened by my code to the mongodb using the db.open function and hence want to know the number of connections that are open. I usually get to see that using "db.serverStatus()" e.g. > db.serverStatus().connections; { "current" : 3, "available" : 19997 } – Ajay Sep 10 '12 at 16:08