Details
-
Bug
-
Resolution: Gone away
-
Major - P3
-
None
-
1.1.0
-
None
-
None
-
Mac OSX
Description
Connecting to a client works fine:
var MongoURI = "mongodb://usermanagement:Jn4LEWxPBuqynRTjz7qd@ds159273.mlab.com:59273/goautoauto-usermanagement" |
var client *mongo.Client
|
// creates an empty option
|
opt := options.Client()
|
opt.ApplyURI(MongoURI)
|
client, err := mongo.NewClient(opt)
|
if err != nil { |
...
|
}
|
In this case I am able to get a client with no error, and connect with no error using the `client.Connect(ctx)` method.
The problem comes when I attempt to do a simple count operation:
n, err = c.client.Database(database).Collection(userCollection).CountDocuments(context.Background(), bson.M{})
|
In this case, I get the error:
error counting documents in user collection: (Unauthorized) not authorized on
|
I am sure that the user/pass used in the URI are correct, as I used the same text when connecting with the Mongo shell (on the shell I do not get any unauthorized errors).