[CXX-676] Cannot connect to replica set using C++ driver Created: 24/Sep/15 Updated: 29/Oct/15 Resolved: 16/Oct/15 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | Release |
| Affects Version/s: | legacy-1.0.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Peter | Assignee: | Adam Midvidy |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | legacy-cxx | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
When using legacy C++ driver, cannot connect to replica set servers. Although I can connect to every member separately with no problem. When multiple servers are specified in connection string, empty pointer is returned from cs.connect(). Code snippet: using namespace mongo; int main() { client::Options opt; DBClientReplicaSet* client = static_cast<DBClientReplicaSet*>(cs.connect(err));
if(client->isMaster(master)) return 0; |
| Comments |
| Comment by Adam Midvidy [ 29/Oct/15 ] |
|
Hi Peter, Did you check that the client machine (running the C++ driver) was able to resolve the hostnames of the replica set nodes? This can be a problem when running on AWS, as the seedlist returned by the server to the driver will return the internal (AWS only) DNS address, which will cause the driver to fail to connect. In the replica set documentation, we remind users to ensure that "each member of a replica set is accessible by way of resolvable DNS or hostnames." (https://docs.mongodb.org/manual/tutorial/deploy-replica-set/). Nonetheless, as this seems like a MongoDB issue (as opposed to a C++ driver issue) I would recommend that you follow up on mongodb-user if you have further questions. Adam |
| Comment by Peter [ 27/Oct/15 ] |
|
Looks, like I found the problem - it is described here: I replicated the steps - namely reconfigured members of replica set not to be identified by hostnames (although DNS was setup and machines were able to communicate using these names), but now containig full host identification: [my service].cloudapp.net:[port] and now the source code works. Would that be possible to add this information to docs somewhere? Thanks for your time. |
| Comment by Peter [ 27/Oct/15 ] |
|
Hi Adam,
I also attached configuration and log from mongo server. |
| Comment by Adam Midvidy [ 16/Oct/15 ] |
|
Hi Peter, I am going to close this issue out. If you are still having trouble, please re-open it. |
| Comment by Adam Midvidy [ 02/Oct/15 ] |
|
Also, I noticed you are building the driver with C+11. Are you building your test executable with C+11 as well? |
| Comment by Adam Midvidy [ 02/Oct/15 ] |
|
Hi Peter, That error would be hit if none of the replica set nodes are reachable at the time the replica set connection his created. Can you elaborate on the configuration of your replica set? What is the # of servers and what version of MongoDB are they running? Also, can you attach MongoDB logs for when this connection failure occurs? Best, |
| Comment by Peter [ 29/Sep/15 ] |
|
Hi, the string says: "connect failed to replica set [replica set name]/[host1]:[port1],[host2]:[port2],[host3]:[port3]" |
| Comment by Adam Midvidy [ 28/Sep/15 ] |
|
Also, what are the contents of the string 'err' after connection fails? |
| Comment by Peter [ 28/Sep/15 ] |
|
Authentication is not enabled, I'm waiting for this basic scenario to work first. |
| Comment by Adam Midvidy [ 25/Sep/15 ] |
|
Hi peto2468@hotmail.com, are you running with auth enabled on your cluster? |