问题
当我尝试使用 C++ 驱动程序将文档插入 MongoDB 时,我收到以下异常消息:
Wed Feb 27 15:21:38 Assertion failure p src/mongo/client/dbclientinterface.h 1096
0 assertion src/mongo/client/dbclientinterface.h:1096
据我所知,它似乎与端口号有关?dbclientinterface.h:1096 包含以下行:
MessagingPort& port() { verify(p); return *p; }
设置连接 (main.cpp)
mongo::DBClientConnection DBConn( "localhost" );
mongo::DBClientConnection DBConn( "localhost:27017" ); // I've also tried this...
插入一个文档 (differ_file.h)
while( m_Entries.size() ){
JsonBox::Value Data( m_Entries.front() );
try {
std::stringstream JSONDoc;
mongo::BSONObj BSONDoc;
Data["doc"].writeToStream( JSONDoc, false );
BSONDoc = mongo::fromjson( JSONDoc.str() );
// std::cout << Data["ns"].getString() << std::endl;
// std::cout << BSONDoc.toString() << std::endl;
// This is where the exception is thrown...
m_DBConn.insert( Data["ns"].getString(), BSONDoc );
} catch( const mongo::DBException& e ){
std::cout << e.toString() << std::endl;
}
m_EntriesMutex.lock();
m_Entries.pop();
m_EntriesMutex.unlock();
}