[CXX-644] auto_reconnect using ConnectionString API Created: 31/Jul/15 Updated: 11/Sep/19 Resolved: 31/Jul/15 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | API |
| Affects Version/s: | legacy-1.0.0 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Judy Han [X] | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux version 2.6.32-504.3.3.el6.x86_64 (mockbuild@x86-028.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-9) (GCC) ) #1 SMP Fri Dec 12 16:05:43 EST 2014 |
||
| Description |
|
If I use DBClientConnection () API to make mongodb connection, I can specify _autoReconnect to be true which allow automatic reconnect on a connection failure. However, I am using following API to connect (recommended way?): ; Thanks in advance! |
| Comments |
| Comment by Judy Han [X] [ 31/Jul/15 ] |
|
Great, Thanks a lot! Please feel free to close the ticket. |
| Comment by Adam Midvidy [ 31/Jul/15 ] |
|
Hi Judy, If your deployment is a replicaSet (i.e. the connection string has the 'replSet' parameter) then autoReconnect is enabled by default, as ConnectionString::connect will return an instance of DBClientReplicaSet. As I mentioned earlier, DBClientReplicaSet always uses autoReconnect. Adam |
| Comment by Judy Han [X] [ 31/Jul/15 ] |
|
Hi Adam, |
| Comment by Adam Midvidy [ 31/Jul/15 ] |
|
Judy.Han, the default value for autoReconnect on DBClientConnection is false. If you would like to specify autoReconnect, you should manually construct an instance of DBClientConnection and pass a value of true to the constructor for the autoReconnect parameter. The reason this is not supported through the ConnectionString::connect() interface is that other connection types, such as DBClientReplicaSet, have different autoReconnect semantics - i.e. for DBClientReplicaSet, autoReocnnect is always enabled. |