Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Unable to connect to MongoDB instance in MongoHQ hosting #42

Closed
aruizca opened this issue May 22, 2013 · 17 comments
Closed

Unable to connect to MongoDB instance in MongoHQ hosting #42

aruizca opened this issue May 22, 2013 · 17 comments
Labels

Comments

@aruizca
Copy link

aruizca commented May 22, 2013

The error I am getting varies depending whether I try to test the connection, where I get this error message:
10:10:05 PM CommandFailure: Error when accessing Mongo server: command failed [$eval]: { "serverUsed" : "alex.mongohq.com/23.22.16.107:10040" , "ok" : 0.0 , "errmsg" : "unauthorized"}
or if I am trying to open the console, where I get this other error message:
connecting to: alex.mongohq.com:10040/test
exception: login failed
Wed May 22 22:14:14.907 JavaScript execution failed: Error: 18 { ok: 0.0, errmsg: "auth fails" } at src/mongo/shell/db.js:L228

why is trying to use the test db name? I can assure you the username and password is correct, so I don't understand that error message. On the other hand I am able to connect using the mongo command line client without any issue.

Cheers,
Angel.

@dboissier
Copy link
Owner

Hi,

I use a MongoLab account to test secured access to remote Mongo server and it works fine.
Did you set the database field in the configuration panel?

Cheers,

David

@aruizca
Copy link
Author

aruizca commented May 23, 2013

capture

@aruizca
Copy link
Author

aruizca commented May 23, 2013

capture

@aruizca
Copy link
Author

aruizca commented May 23, 2013

This trace might also help you:

Error when accessing Mongo server: command failed [$eval]: { "serverUsed" : "alex.mongohq.com/23.22.16.107:10040" , "ok" : 0.0 , "errmsg" : "unauthorized"}
com.mongodb.CommandResult$CommandFailure: command failed [$eval]: { "serverUsed" : "alex.mongohq.com/23.22.16.107:10040" , "ok" : 0.0 , "errmsg" : "unauthorized"}
    at com.mongodb.CommandResult.getException(CommandResult.java:88)
    at com.mongodb.CommandResult.throwOnError(CommandResult.java:134)
    at com.mongodb.DB.eval(DB.java:371)
    at org.codinjutsu.tools.mongo.logic.MongoManager.connectAndReturnServerVersion(MongoManager.java:63)
    at org.codinjutsu.tools.mongo.view.ServerConfigurationPanel$1.actionPerformed(ServerConfigurationPanel.java:85)

It looks to me that in your connectAndReturnServerVersion you are requesting something for which a normal user of this cloud service do not have authorization. It might be enough controlling that exception. If I have a time I'll have a look to your source code

Cheers,
Angel.

@dboissier
Copy link
Owner

Hi,

actually, I look for the server version.

db.version();

Indeed, the aggregation feature is only available from mongo 2.2. In that case, aggregation query panel is displayed instead of a simple query panel.

However the mongo terminal only uses the executable defined in your path and all parameters are passed in the command line according to the man documentation.

So, I think you may have an authentication issue with your remote mongo server.

Cheers,

David

@dboissier
Copy link
Owner

Hi,

Sorry for the last response. There is a bug when you want to use the console. It does not pass the database parameter.

Here below the behavior:
When a database or a collection is selected in the explorer then the console connects with the selected database
Or else it connects with the "test" database.

@dboissier
Copy link
Owner

Hi,

A snapshot is available on the home page of the project and fix the above bug found whenever you want to use the console.

I am not sure if it fixes the pb you described at the begining of this conversation.

Tell me if you have more info about it.

Regards,

David

@aruizca
Copy link
Author

aruizca commented Jun 12, 2013

Still no luck. This is the only MongoDB client that I cannot use to connect to my DB instance in MongoHQ. I connect with MongoVUE with no issues whatsoever:

rror when accessing Mongo server: command failed [$eval]: { "serverUsed" : "alex.mongohq.com/23.22.16.107:10029" , "ok" : 0.0 , "errmsg" : "unauthorized"}
com.mongodb.CommandResult$CommandFailure: command failed [$eval]: { "serverUsed" : "alex.mongohq.com/23.22.16.107:10029" , "ok" : 0.0 , "errmsg" : "unauthorized"}
    at com.mongodb.CommandResult.getException(CommandResult.java:88)
    at com.mongodb.CommandResult.throwOnError(CommandResult.java:134)
    at com.mongodb.DB.eval(DB.java:371)
    at org.codinjutsu.tools.mongo.logic.MongoManager.connectAndReturnServerVersion(MongoManager.java:63)
    at org.codinjutsu.tools.mongo.view.ServerConfigurationPanel$1.actionPerformed(ServerConfigurationPanel.java:90)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:700)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:521)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
    at java.awt.Dialog.show(Dialog.java:1082)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:706)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:399)
    at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1460)
    at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1435)
    at org.codinjutsu.tools.mongo.view.MongoConfigurable$1$3.run(MongoConfigurable.java:143)
    at org.codinjutsu.tools.mongo.view.MongoConfigurable$1$3.run(MongoConfigurable.java:134)
    at com.intellij.ui.ToolbarDecorator$4.doAdd(ToolbarDecorator.java:427)
    at com.intellij.ui.CommonActionsPanel$Buttons.performAction(CommonActionsPanel.java:65)
    at com.intellij.ui.CommonActionsPanel$MyActionButton.actionPerformed(CommonActionsPanel.java:222)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:162)
    at com.intellij.openapi.actionSystem.impl.ActionButton.a(ActionButton.java:169)
    at com.intellij.openapi.actionSystem.impl.ActionButton.a(ActionButton.java:132)
    at com.intellij.openapi.actionSystem.impl.ActionButton.processMouseEvent(ActionButton.java:310)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:700)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:521)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
    at java.awt.Dialog.show(Dialog.java:1082)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:706)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:399)
    at com.intellij.openapi.ui.DialogWrapper.showAndGetOk(DialogWrapper.java:1460)
    at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1435)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.showSettingsDialog(ShowSettingsUtilImpl.java:104)
    at org.codinjutsu.tools.mongo.view.action.OpenPluginSettingsAction.showSettingsFor(OpenPluginSettingsAction.java:45)
    at org.codinjutsu.tools.mongo.view.action.OpenPluginSettingsAction.actionPerformed(OpenPluginSettingsAction.java:41)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:162)
    at com.intellij.openapi.actionSystem.impl.ActionButton.a(ActionButton.java:169)
    at com.intellij.openapi.actionSystem.impl.ActionButton.a(ActionButton.java:132)
    at com.intellij.openapi.actionSystem.impl.ActionButton.processMouseEvent(ActionButton.java:310)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:702)
    at java.awt.EventQueue$4.run(EventQueue.java:700)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
    at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:700)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:521)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

@dboissier
Copy link
Owner

Hi Alex,

I see a kind of IP address in the mongo URL : alex.mongohq.com/ 23.22.16.107 :10029

I am not sure to understand this. Do you have any info about it?

Thanks,

David

@baklinger
Copy link

I've tried to use the new snapshot but the problem with default connection to "test" database still occur. I think the problem is in the org.codinjutsu.tools.mongo.logic.MongoManager. The "createMongoClient" should get the third parameter i.e. "String userDatabase" and the "textURI" variable inside that method should take into account this parameter:

String textURI = String.format("mongodb://%s:%s%s", serverName, serverPort,
(userDatabase != null && !userDatabase.equals("")) ? "/" + userDatabase : "");

Any "createMongoClient" call should be also updated.

@dboissier
Copy link
Owner

Hi,

Thanks for reporting that.

Actually, MongoLab allows to connect to your account without specifiying the database. So I did in that way and make the authentication to the user database after.

I suppose MongoHQ only allows full mongo URI.

I will update the code. A snapshot should be available in a couple of hours.

Regards,

David

@dboissier
Copy link
Owner

Hi,

Please download the latest snapshot and tell me if it works.

Regards,

David

@baklinger
Copy link

Unfortunately the problem seems to be deeper. I still have the same "unauthorised" exception:

Error when accessing Mongo server: command failed [$eval]: { "serverUsed" : "localhost/127.0.0.1:27017" , "ok" : 0.0 , "errmsg" : "unauthorized"}
com.mongodb.CommandResult$CommandFailure: command failed [$eval]: { "serverUsed" : "localhost/127.0.0.1:27017" , "ok" : 0.0 , "errmsg" : "unauthorized"}
at com.mongodb.CommandResult.getException(CommandResult.java:88)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:134)
at com.mongodb.DB.eval(DB.java:371)
at org.codinjutsu.tools.mongo.logic.MongoManager.connectAndReturnServerVersion(MongoManager.java:63)
at org.codinjutsu.tools.mongo.logic.MongoManager.connect(MongoManager.java:43)
at org.codinjutsu.tools.mongo.view.MongoExplorerPanel$1.run(MongoExplorerPanel.java:119)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:343)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:700)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:525)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:348)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

On the MongoDB side I've got:

Wed Jun 12 13:46:00.664 [initandlisten] connection accepted from 127.0.0.1:49703 #28 (1 connection now open)
Wed Jun 12 13:46:00.664 [conn28] run command admin.$cmd { isMaster: 1 }
Wed Jun 12 13:46:00.664 [conn28] command admin.$cmd command: { isMaster: 1 } ntoreturn:1 keyUpdates:0 reslen:115 0ms
Wed Jun 12 13:46:00.665 [conn28] run command myfd.$cmd { getnonce: 1 }
Wed Jun 12 13:46:00.665 [conn28] command myfd.$cmd command: { getnonce: 1 } ntoreturn:1 keyUpdates:0 reslen:65 0ms
Wed Jun 12 13:46:00.665 [conn28] run command myfd.$cmd { authenticate: 1, user: "myfd_admin", nonce: "1dad3e1d07670bad", key: "0cff82b107990a184839911c7d9a7345" }
Wed Jun 12 13:46:00.665 [conn28] authenticate db: myfd { authenticate: 1, user: "myfd_admin", nonce: "1dad3e1d07670bad", key: "0cff82b107990a184839911c7d9a7345" }
Wed Jun 12 13:46:00.665 [conn28] command myfd.$cmd command: { authenticate: 1, user: "myfd_admin", nonce: "1dad3e1d07670bad", key: "0cff82b107990a184839911c7d9a7345" } ntoreturn:1 keyUpdates:0 locks(micros) r:152 reslen:75 0ms
Wed Jun 12 13:46:00.666 [conn28] run command myfd.$cmd { getnonce: 1 }
Wed Jun 12 13:46:00.666 [conn28] command myfd.$cmd command: { getnonce: 1 } ntoreturn:1 keyUpdates:0 reslen:65 0ms
Wed Jun 12 13:46:00.666 [conn28] run command myfd.$cmd { authenticate: 1, user: "myfd_admin", nonce: "7cc61ff6c3e152bf", key: "f94e10262b7a9c896f3ec0667b05646c" }
Wed Jun 12 13:46:00.666 [conn28] authenticate db: myfd { authenticate: 1, user: "myfd_admin", nonce: "7cc61ff6c3e152bf", key: "f94e10262b7a9c896f3ec0667b05646c" }
Wed Jun 12 13:46:00.666 [conn28] command myfd.$cmd command: { authenticate: 1, user: "myfd_admin", nonce: "7cc61ff6c3e152bf", key: "f94e10262b7a9c896f3ec0667b05646c" } ntoreturn:1 keyUpdates:0 locks(micros) r:122 reslen:75 0ms
Wed Jun 12 13:46:00.667 [conn28] run command myfd.$cmd { $eval: "db.version();", args: {} }
Wed Jun 12 13:46:00.667 [conn28] Privilege acquisition failed for myfd_admin@myfd in database : Bad database name "" (BadValue)
Wed Jun 12 13:46:00.667 [conn28] command denied: { $eval: "db.version();", args: {} }
Wed Jun 12 13:46:00.667 [conn28] command myfd.$cmd command: { $eval: "db.version();", args: {} } ntoreturn:1 keyUpdates:0 reslen:62 0ms
Wed Jun 12 13:46:00.669 [conn28] end connection 127.0.0.1:49703 (0 connections now open)

@dboissier
Copy link
Owner

Hi,

Wed Jun 12 13:46:00.667 [conn28] run command myfd.$cmd { $eval: "db.version();", args: {} }
Wed Jun 12 13:46:00.667 [conn28] Privilege acquisition failed for myfd_admin@myfd in database : Bad database name "" (BadValue)

I read Bad database name (BadValue)

Any idea of that?

David

@dboissier
Copy link
Owner

A snapshot is available.

Please tell me if it is ok before I officially release 0.4.3

@baklinger
Copy link

I think it's OK. The new snapshot works well with my IntelliJ IDEA 12.1.4.
Thanks.

@aruizca
Copy link
Author

aruizca commented Jul 24, 2013

I forgot to reply to this. It works fine now with the latest version. Thanks so much.

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

No branches or pull requests

3 participants