-
Type: Bug
-
Resolution: Cannot Reproduce
-
Priority: Major - P3
-
None
-
Affects Version/s: legacy-1.0.5
-
Component/s: Release
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:
#include <mongo/client/dbclient.h>
#include <mongo/client/options.h>
#include <mongo/client/init.h>
#include <mongo/bson/bson.h>
#include <iostream>
#include <memory>
#include <iostream>
using namespace mongo;
using namespace std;
int main() {
string rsName = "myProductionSet";
string err;
bool master;
client::Options opt;
client::initialize(opt);
ConnectionString cs = ConnectionString::parse("mongodb://[host1]:27017,[host2]:27117/?replicaSet=myProductionSet",err);
DBClientReplicaSet* client = static_cast<DBClientReplicaSet*>(cs.connect(err));
if(!client)
if(client->isMaster(master))
std::cout << "OK" << std::endl;
else
std::cout << "ERR" << std::endl;
return 0;
}