- Home /
MongoDB C# authentication exception
Hi guys,
My database is hosted in mlab.com and I tried to connect it using mongodb C# driver but I am getting following exception when I try to connect to the mlab database.
MongoCommandException: Command 'saslStart' failed: Authentication failed. (response: { "ok" : 0.0, "code" : 18, "errmsg" : "Authentication failed." }) MongoDB.Driver.Operations.CommandOperation`1[MongoDB.Driver.CommandResult].Execute (MongoDB.Driver.Internal.MongoConnection connection) MongoDB.Driver.Communication.Security.SaslAuthenticationProtocol.RunCommand (MongoDB.Driver.Internal.MongoConnection connection, System.String databaseName, IMongoCommand command) MongoDB.Driver.Communication.Security.SaslAuthenticationProtocol.Authenticate (MongoDB.Driver.Internal.MongoConnection connection, MongoDB.Driver.MongoCredential credential) Rethrow as MongoSecurityException: Error: 18 - Authentication failed. MongoDB.Driver.Communication.Security.SaslAuthenticationProtocol.Authenticate (MongoDB.Driver.Internal.MongoConnection connection, MongoDB.Driver.MongoCredential credential) MongoDB.Driver.Communication.Security.Authenticator.Authenticate (MongoDB.Driver.MongoCredential credential) MongoDB.Driver.Communication.Security.Authenticator.Authenticate () MongoDB.Driver.Internal.MongoConnection.Open () MongoDB.Driver.Internal.MongoConnection.GetNetworkStream () MongoDB.Driver.Internal.MongoConnection.SendMessage (MongoDB.Bson.IO.BsonBuffer buffer, Int32 requestId) Rethrow as MongoConnectionException: Unable to connect to server dsXXXXXX.mlab.com:XXXXX: Error: 18 - Authentication failed.. MongoDB.Driver.Internal.DirectMongoServerProxy.Connect (TimeSpan timeout, MongoDB.Driver.ReadPreference readPreference) MongoDB.Driver.MongoServer.Connect (TimeSpan timeout) MongoDB.Driver.MongoServer.Connect ()
Below is the line which throws the error.
client = new MongoClient (new MongoUrl("mongodb://:@dsxxxxx.mlab.com:xxxxx/mydb"));
And the db user has admin rights as well...username and password are also correct..Need some help :-)
this doesn't directly relate to unity so you might have more success at somewhere like stack overflow