selectel / mongoDB-haskell

MongoDB driver for Haskell
http://hackage.haskell.org/package/mongoDB
Apache License 2.0
21 stars 11 forks source link

Connecting to External URI #28

Open Trajanson opened 6 years ago

Trajanson commented 6 years ago
mongoURI = "127.0.0.1"
pipe <- connect (host mongoURI)

works fine, but if I replace mongoURI with a URI provided by mongoDBAtlas, then I receive an error

the URIs suggested by MongoDBAtlas are: "mongodb+srv://" ++ mongoUsername ++ ":" ++ mongoPassword ++ "@databaseName.azure.mongodb.net/test"

or "mongodb://" ++ mongoUsername ++ ":" ++ mongoPassword ++ "@databaseName-shard-00-00-qxoqe.azure.mongodb.net:27017,databaseName-shard-00-01-qxoqe.azure.mongodb.net:27017,databaseName-shard-00-02-qxoqe.azure.mongodb.net:27017/test?ssl=true&replicaSet=databaseName-shard-0&authSource=admin"

this results in the following error:

*** Exception: Network.Socket.getAddrInfo (called with preferred socket type/protocol: AddrInfo {addrFlags = [AI_ADDRCONFIG], addrFamily = AF_UNSPEC, addrSocketType = Stream, addrProtocol = 6, addrAddress = <assumed tobe undefined>, addrCanonName = <assumed to be undefined>}, host name: Just "mongodb+srv://mongoUsernameIsHere:mongoPasswordIsHere@databaseNameIsHere-qxoqe.azure.mongodb.net/test", service name: Just "27017"): does not exist (nodename nor servname provided, or not known)

port is 27017 in line with default

narley commented 5 years ago

Just came across this issue trying to connect to mlab. Have you came up with a solution @Trajanson ?