【发布时间】:2019-06-13 05:34:22
【问题描述】:
如何更改因服务器无法访问而可能失败的不同操作的超时时间? (start_session, insert, find, delete, update, ...)
...
auto pool = mongocxx::pool(mongocxx::uri("bad_uri"), pool_options);
auto connection = pool.try_acquire();
auto db = (*(connection.value()))["test_db"];
auto collection = db["test_collection"];
// This does not help
mongocxx::write_concern wc;
wc.timeout(std::chrono::milliseconds(1000));
mongocxx::options::insert insert_options;
insert_options.write_concern(wc);
// takes about 30 seconds to fail
collection.insert_one(from_json(R"({"name": "john doe", "occupation": "_redacted_", "skills" : "a certain set"})"), insert_options);
[编辑]
这是异常消息:
C++ 异常,描述为“未找到合适的服务器:
serverSelectionTimeoutMS过期:【连接超时调用 ismaster on '127.0.0.1:27017']
【问题讨论】:
标签: c++ mongodb mongo-cxx-driver