bobthecow / genghis

The single-file MongoDB admin app
http://genghisapp.com
MIT License
1.45k stars 163 forks source link

Can't seem to connect to a meteor.com hosted Mongo #102

Open julien-c opened 11 years ago

julien-c commented 11 years ago

Meteor provides hosting for Meteor apps on meteor.com.

meteor mongo --url yoursite.meteor.com returns a DSN that can be used in mongo or mongodump for instance, that looks like:

mongodb://client:1f8ef04d-fe88-fa15-e666-463e7682a52a@c0.meteor.m0.mongolayer.com:27017/yoursite_meteor_com

However, I can't seem to connect to this server from Genghis. Any idea why?

Thanks!

bobthecow commented 11 years ago

Meteor appears to be generating single-use passwords every time you call meteor mongo --url ... this means that for the initial connection, Genghis might be able to access the Mongo instance, but as soon as it makes a second request it's denied. Since Genghis tries to make an initial connection when you add the server DSN (during the POST request) it succeeds and adds the server. But when you do a GET request to list the available servers, which happens immediately after that initial POST request, Meteor rejects your password.

This can be verified by running meteor mongo --url multiple times in a row. Each time you'll get a new password.

It can also be verified by trying to connect the Mongo command line client to the same Meteor DSN twice in a row. The first time connects:

MongoDB shell version: 2.4.1
connecting to: c0.meteor.m0.mongolayer.com:27017/genghistest_meteor_com
Error while trying to show server startup warnings: need to login
> show collections
system.indexes
system.users
>
bye

... but the second time doesn't:

MongoDB shell version: 2.4.1
connecting to: c0.meteor.m0.mongolayer.com:27017/genghistest_meteor_com
Sun Apr 14 12:55:02.483 JavaScript execution failed: Error: 18 { errmsg: "auth fails", ok: 0.0 } at src/mongo/shell/db.js:L228
exception: login failed

Unfortunately, I don't think there's much Genghis can do here.

julien-c commented 11 years ago

I guess the only solution would be to have a long-running connection to the MongoDB server, and have the Genghis API pass queries to the connected process? Probably a pretty significant architectural change though :)

By the way, off topic, but have you given any thought to real-time (or even more complex, real-time collaborative) in Genghis? For example based on Meteor or Angular?

bobthecow commented 11 years ago

I'm reclassifying this as a "feature" instead of "bug" since it's not possible to support meteor.com hosted mongo with the current architecture.

olizilla commented 11 years ago

As a workaround, you can take a mongodump from an app hosted on http://meteor.com and then restore it to a local mongo to have a poke around. Useful for backups and offline analytics rather than live-noodling your production app.

Here's the gist: https://gist.github.com/olizilla/5209369

In other news, thanks for making genghis. I'd been struggling to find a decent mongodb peruser since I made that gist, and now I can peruse my dumps in style...

julien-c commented 11 years ago

Actually, there _is_ a way to use Genghis directly on your meteor.com hosted app. You can console.log the actual, permanent Mongo connection info server side process.env.MONGO_URL and retrieve it.

To quote @n1mmy from Meteor though:

Be careful though, because we don't expose a good way to change your database password short of deleting the app and re-deploying.

chadokruse commented 11 years ago

Would love to see a collaboration/combination of Genghis with meteor-admin-ui

AlexeyMK commented 11 years ago

Hey chad! We drew quite a bit of inspiration from Genghis, though I'm not sure what more we could take; Genghis is not trivially packaged as a Meteor plugin, and a hosted solution would require trusting a third party with your DB url.