mongodb-erlang icon indicating copy to clipboard operation
mongodb-erlang copied to clipboard

Example for connecting to multiple replicas on Mongo Atlas

Open Spoowy opened this issue 6 years ago • 6 comments

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

Spoowy avatar Dec 02 '18 14:12 Spoowy

Have you tried with mongo_api and multiple hosts?

comtihon avatar Dec 27 '18 13:12 comtihon

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

grizzly-monkey avatar Dec 30 '18 13:12 grizzly-monkey

Hi, this worked for me:

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

pedro-gutierrez avatar Jan 05 '19 20:01 pedro-gutierrez

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. )

wandermyz avatar Jan 24 '19 20:01 wandermyz

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

liujp-arch avatar May 06 '20 05:05 liujp-arch

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

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

Spoowy avatar May 14 '20 14:05 Spoowy