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

From: Wan Bachtiar <wan.bachtiar@xxxxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Tue, 3 May 2016 21:17:43 -0700 (PDT)
Why ads?


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 
<https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst>. 
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 
<https://docs.mongodb.org/manual/reference/glossary/#term-failover>.

Also see the following resources related to reconnection and retries : 

   - Video: MongoDB Drivers and High Availability Deep Dive 
   <https://www.mongodb.com/presentations/mongodb-drivers-and-high-availability-deep-dive
   - Blog: Server discovery and monitoring next generation MongoDB drivers 
   <https://www.mongodb.com/blog/post/server-discovery-and-monitoring-next-generation-mongodb-drivers
   - Server Discovery and Monitoring in MongoDB Drivers 
   <https://emptysqua.re/blog/server-discovery-and-monitoring-in-mongodb-drivers/
   - MongoDB C Driver cursor errors 
   <http://api.mongodb.org/c/current/cursors.html#cursor-errors
   - Previous forum post: MongoDB C Driver retry operations 
   <https://groups.google.com/forum/#!msg/mongodb-user/1ATQ1t7h8tA/jZB1IXbzAAAJ

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 
<https://docs.mongodb.org/manual/reference/program/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 
<https://docs.mongodb.org/manual/core/sharding/#sharding-concepts> for more 
information. 

Regards, 

Wan. 


-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/c14d8f12-7aa9-4a98-b0f3-ed6513a146a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Why ads?