Problems connecting to replica set from C++ 1.0.3 driver

69 views
Skip to first unread message

sga

unread,
Jul 30, 2015, 7:07:06 PM7/30/15
to mongodb-user
Hi All,

We're upgrading from 2.x to 3.0.4 and are having difficulty connecting to a fresh 3.0.4 replica set via the C++ 1.0.3 driver.  If the connection string contains just a single member of the set, connection/auth works perfectly, but if all replica set members are specified, auth fails.  Using either mongo::DBClientReplicaSet or mongo::ConnectionString::connect results in the same failure behavior.

When multiple members of a set are specified, the driver does not detect that it's connecting to a Mongo 3 instance, and will attempt to use MONGO-CR instead of SCRAM-SHA1.  Tracing through the client code, the client is setting its minimum and maximum wireline versions to (0,0) instead of (0,3) when connecting to the 3.0.4 replica set, which then causes it to default to MONGO-CR as its authentication mechanism.  If we add code to detect the wireline version after making a connection (as is done by the driver when connecting to a single machine), the authentication type is set correctly and authentication succeeds.

Are we doing something wrong or is this a defect in the driver?  FWIW, connecting to the same replica sets with the Python driver works as expected when all members are listed...

A stripped-down code sample using mongo::DBClientReplicaSet is as follows.

const auto SetWirelineVersion = [](mongo::DBClientBase& connection)
{
  mongo::BSONObj info;
  if (connection.simpleCommand("admin", &info, "ismaster"))
  {
    if (info.hasField("maxWireVersion"))
      connection.setWireVersions(0, info.getIntField("maxWireVersion"));
  }
};

std
::vector<mongo::HostAndPort> servers;
servers
.push_back(mongo::HostAndPort("192.168.0.37:27017"));
servers
.push_back(mongo::HostAndPort("192.168.0.37:27018"));
servers
.push_back(mongo::HostAndPort("192.168.0.37:27019"));
mongo
::DBClientReplicaSet c("rs0", servers);

const bool connected = c.connect();

//Without setting the wireline version explicitly, the client will try and use MONGODB-CR
//SetWirelineVersion(c);

std
::string error;
const bool auth = c.auth("test", "user", "password", error, true);


adam.m...@10gen.com

unread,
Jul 31, 2015, 1:03:17 PM7/31/15
to mongodb-user, stevea...@gmail.com
Hello,

Thanks for the detailed description. I would encourage you to file a ticket on the CXX project on the MongoDB JIRA. Please include the text of this message and attach a full C++ program that reproduces the issue along with a description of the expected behavior. At that point we can begin the process of reproducing the issue on our side.

Thanks,
Adam
Reply all
Reply to author
Forward
0 new messages