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.