mongodb-erlang
mongodb-erlang copied to clipboard
Example for connecting to multiple replicas on Mongo Atlas
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
Have you tried with mongo_api and multiple hosts?
I think this is same as #196 , this is a much needed feature.
Hi, this worked for me:
{ok, Pid} = mongoc:connect( {rs, <<"...">>, [
"....mongodb.net:27017",
"....mongodb.net:27017",
"....mongodb.net:27017"
]}, [], [
{database,<<"...">>},
{login,<<"...">>},
{password,<<"...">>},
{ssl, true}
]).
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. )
when i add {ssl, true}, it always show a timeout operation.
(I switched to Sergej's erlmongo package and added ssl support.
https://github.com/SergejJurecko/erlmongo)