简体   繁体   English

MongoCXX 3.4-使用Unix域套接字URI

[英]MongoCXX 3.4 - Using a unix domain socket URI

I am trying to connect to MongoDB via the c++ driver. 我正在尝试通过c ++驱动程序连接到MongoDB。 If I provide the IP based URI everything works fine, however when I try to use a unix domain socket URI I get the following error: 如果我提供基于IP的URI,则一切正常,但是,当我尝试使用unix域套接字URI时,出现以下错误:

an invalid MongoDB URI was provided

I am trying to connect in the following way: 我正在尝试通过以下方式进行连接:

mongocxx::uri uri{"mongodb:///tmp/mongodb-27017.sock"};                                  
mongocxx::pool *p = new mongocxx::pool (uri); 

If I replace the uri string with mongodb://localhost:27017/?minPoolSize=0&maxPoolSize=10 , it works just fine. 如果我将uri字符串替换为mongodb://localhost:27017/?minPoolSize=0&maxPoolSize=10 ,它就可以正常工作。

I am probably doing something wrong, not sure what though. 我可能做错了,但不确定。

You need to add a trailing / . 您需要添加尾随/ Try mongocxx::uri uri{"mongodb:///tmp/mongodb-27017.sock/"}; 试试mongocxx::uri uri{"mongodb:///tmp/mongodb-27017.sock/"}; .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM