[CXX-368] Lazily call ismaster instead of doing it during connect Created: 06/Oct/14  Updated: 07/Jan/15  Resolved: 07/Jan/15

Status: Closed
Project: C++ Driver
Component/s: Implementation
Affects Version/s: legacy-1.0.0-rc0
Fix Version/s: None

Type: Improvement Priority: Blocker - P1
Reporter: Tyler Brock Assignee: Unassigned
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

We shouldn't be calling isMaster during the DBClientConnection::_connect method:

https://github.com/mongodb/mongo-cxx-driver/blob/legacy/src/mongo/client/dbclient.cpp#L1398

We should populate server version specific values (like maxBsonObjectSize) upon the first request instead.



 Comments   
Comment by Tyler Brock [ 22/Dec/14 ]

Hey Alex, I'm going to move your question into it's own ticket: CXX-456

Comment by Alex Hultman [ 22/Dec/14 ]

Hi.

I'm having some strange problems with the C++ driver. I have been digging for some time.

I'm programming against Fedora 21's libmongoclient (2.4.9) and it works. But since I'm deploying to Amazon I need to compile statically so I clone from mongo-cxx-driver. This worked fine last week, but today I pulled the latest rc3 and now I can't even get the hello world app to work (slightly modified):

#include <cstdlib>
#include <iostream>
#include <string>
#include "mongo/client/dbclient.h" // for the driver
using namespace std;

void run() {
mongo::DBClientConnection c;

string host = "127.0.0.1";
mongo::HostAndPort hp(host, 27017);

string err;
c.connect(hp, err);
}

int main() {
mongo::client::initialize();
try

{ run(); std::cout << "connected ok" << std::endl; }

catch( const mongo::DBException &e )

{ std::cout << "caught " << e.what() << std::endl; }

return EXIT_SUCCESS;
}

This code, and my fails to connect and throws this exception:

caught DBClientBase::findN: transport error: 127.0.0.1:27017 ns: admin.$cmd query:

{ ismaster: 1 }

I tried resetting to rc2 and that revision actually connects without exceptions and I can download a BSONObject, however - this version just returns EOO for fields that actually exists (I can see them in Robomongo and the whole program works with Fedora's libmongoclient).

But since I cannot even get the hello world sample to work something has to be wrong.

I'm compiling with:

sudo scons --prefix=/usr --ssl -j 8 install

And I'm cloning with:

git clone https://github.com/mongodb/mongo-cxx-driver.git

Generated at Wed Feb 07 21:59:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.