Does mongo c driver has the function of auto re-connection?

40 views
Skip to first unread message

朱金栋 Zhujindong

unread,
Apr 21, 2016, 4:32:37 AM4/21/16
to mongodb-user
I use the mongo c driver to operate the mongodb ,i just wonder if the driver has the function of auto re-connection? 
And if I use a mongodb cluster with three shards ,how can i connect all of the mongos? 
And how can I do to switch to another mongos when i am using one of the mongos to operate the DB?
Help is welcome.
thanks!

Wan Bachtiar

unread,
May 4, 2016, 12:17:43 AM5/4/16
to mongodb-user

I use the mongo c driver to operate the mongodb ,i just wonder if the driver has the function of auto re-connection?

Hi Zhujin,

The C Driver, like all drivers, implement the Server Discovery and Monitoring Spec. In the case of a standalone mongod, the driver is able to reconnect once the server recovered. In a replica set case, the driver will do a rescan and figures out the new primary after a failover.

Also see the following resources related to reconnection and retries :

if I use a mongodb cluster with three shards ,how can i connect all of the mongos?

Generally, in a sharded cluster it is recommended that an application connects to a mongos instead of the shards primary individually. A mongos instance route the reads and writes from application(s) to the shards. An application don’t normally connect to more than one mongos.

See also Sharding Concepts for more information.

Regards,

Wan.

Reply all
Reply to author
Forward
0 new messages