2

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.

user3690467
  • 3,049
  • 6
  • 27
  • 54

1 Answers1

0

You need to add a trailing /. Try mongocxx::uri uri{"mongodb:///tmp/mongodb-27017.sock/"};.

acm
  • 12,183
  • 5
  • 39
  • 68