Caused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): ‘Authentication failed.’ on server localhost:33132. The full response is {“ok”: 0.0, “errmsg”: “Authentication failed.”, “code”: 18, “codeName”: “AuthenticationFailed”}
The environment is ppc64le/UBI 8.3 (RHEL 8.3 based container environment).
MongoDB server version: 4.4.4
Mongo driver version: 3.12.8
Mongo server container logs:
MongoDB server version: 4.4.4
From mongo client:
Create a MongoClient(MongoClientURI) instance with MongoClientURI(mongodb://test:password@hostip:port/dbName) and connect with server.
Any pointers help would be great.
Revert back, if more information required.
I suspect the issue is with the connection string. Appending /dbName to it indicates that the credential is defined in the dbName database, but it’s likely that it’s actually defined in the admin database. Try removing /dbName from the connection string and see if it works.
Caused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): ‘Authentication failed.’ on server hostip:port. The full response is {“ok”: 0.0, “errmsg”: “Authentication failed.”, “code”: 18, “codeName”: “AuthenticationFailed”}
FYI, I tried the same code with x86_64 and no authentication errors observed. This is specific to PowerPc64.
com.mongodb.MongoNodeIsRecoveringException: Command failed with error 11600 (InterruptedAtShutdown): ‘Index build failed: 03c6cb78-341b-4789-bf06-b1872ed7876a: Collection graylog.grants ( 01a76922-bca4-43a7-a3ad-790b57c17002 ) :: caused by :: interrupted at shutdown’ on server docker0 Ip:33792. The full response is {“ok”: 0.0, “errmsg”: “Index build failed: 03c6cb78-341b-4789-bf06-b1872ed7876a: Collection graylog.grants ( 01a76922-bca4-43a7-a3ad-790b57c17002 ) :: caused by :: interrupted at shutdown”, “code”: 11600, “codeName”: “InterruptedAtShutdown”}
com.mongodb.MongoCommandException: Command failed with error 13 (Unauthorized): ‘command dropDatabase requires authentication’ on server docker0 Ip:33792. The full response is {“ok”: 0.0, “errmsg”: “command dropDatabase requires authentication”, “code”: 13, “codeName”: “Unauthorized”}
To resolve this issue added user:pass@ to the MogoClientURI and finally ended with “com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName=‘test’” issue.
As Jeff says there shouldn’t be any behavioural difference between authentication and server architectures.
The exception:
Command failed with error 18 (AuthenticationFailed): ‘Authentication failed.’ on server hostip:port.
The full response is {“ok”: 0.0, “errmsg”: “Authentication failed.”, “code”: 18, “codeName”:
“AuthenticationFailed”}
Looks as expected with an invalid username / password combination.
Shows that it is failing but using the expected mechanism against the admin database. You could try an connection string that sets the authSource and authMechanism explicitly:
Caused by: com.mongodb.MongoCommandException: Command failed with error 18 (AuthenticationFailed): ‘Authentication failed.’ on server docker0 Ip:34121. The full response is {“ok”: 0.0, “errmsg”: “Authentication failed.”, “code”: 18, “codeName”: “AuthenticationFailed”}