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

Cannot connect to remote Mongo server #55

Closed
hieuht817 opened this issue Mar 6, 2015 · 3 comments
Closed

Cannot connect to remote Mongo server #55

hieuht817 opened this issue Mar 6, 2015 · 3 comments

Comments

@hieuht817
Copy link

This driver seems very nice. I use it in my elixir project.
This is my code to connect to my remote mongo server. But it returns error.

iex> :mongo.connect("db_name", "account", "password", "safe", "master", [{"host", "example.com"}, {"port", 27017}])
** (EXIT from #PID<0.88.0>) {:errmsg, "auth failed", :code, 18}

(I've tried to connect by my local mongo client and it works.)
Is this right format of the :mongo.connect/6 command when use in elixir?
Please help me!

@hieuht817 hieuht817 changed the title Cannot connect to remote server Cannot connect to remote Mongo server Mar 6, 2015
@comtihon
Copy link
Owner

comtihon commented Mar 7, 2015

According to spec of connect :

-spec connect(database(), bson:utf8(), bson:utf8(), write_mode(), read_mode(), proplists:proplist()) -> {ok, pid()}.

Database should be binary or atom, UserName and Password should be binaries, write and read modes should be atoms.
Correct your connect code and try again. I think it is a problem.

@hieuht817
Copy link
Author

Thank you a lot for response soon!
I've tried to modify the code as below:

iex> :mongo.connect(:db_name, "account", "password", :safe, :master, [{"host", "example.com"}, {"port", 27017}])
** (EXIT from #PID<0.88.0>) {:errmsg, "auth failed", :code, 18}

And still face the same error.

Do you have any idea about this problem?

@hieuht817
Copy link
Author

We've solved the connection issue by modify code to this:

:mongo.connect(:db_name, "account", "password", :safe, :master, [{:host, 'example.com'}, {:port, 27017}])

Thank for your supporting.
Anw, could you make the api more consistent for Elixir? It will be much more helpful.

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