I am trying to connect to MongoDB via the c++ driver. 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:
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.
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/"};
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.