comtihon / mongodb-erlang

MongoDB driver for Erlang
Apache License 2.0
342 stars 267 forks source link

Example for connecting to multiple replicas on Mongo Atlas #207

Open Spoowy opened 5 years ago

Spoowy commented 5 years ago

I had great success with this package, and could connect to my Mongo Atlas Cluster.

Right now, I am connected to the primary server, via mc_worker_api. Any advice on how to connect to a Mongo Atlas replica cluster properly?

Cheers, Erwin

comtihon commented 5 years ago

Have you tried with mongo_api and multiple hosts?

grizzly-monkey commented 5 years ago

I think this is same as #196 , this is a much needed feature.

pedro-gutierrez commented 5 years ago

Hi, this worked for me:

{ok, Pid} = mongoc:connect( {rs, <<"...">>, [ 
    "....mongodb.net:27017",
    "....mongodb.net:27017",
    "....mongodb.net:27017"
]}, [], [
    {database,<<"...">>},
    {login,<<"...">>},
    {password,<<"...">>},
        {ssl, true}
]).
wandermyz commented 5 years ago

It works for me as soon as I add {ssl, true} as @pedro-gutierrez says. It even works if I just specify { unknown, [ ... ] } instead of rs.

(Note that it never works for me when using escript. )

liujp-arch commented 4 years ago

when i add {ssl, true}, it always show a timeout operation.

Spoowy commented 4 years ago

(I switched to Sergej's erlmongo package and added ssl support.

https://github.com/SergejJurecko/erlmongo)