mongodb / mongodb/mongo-php-driver
Sporadic "Authentication failed" errors
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 923
- Forks
- 218
- Avg merge
- 15h 15m
- Merged PRs (30d)
- 32
Description
I know this isn't too helpful of a report, so my feelings won't be hurt if you just close it :)
I noticed I had a connection string of the form
mongodb+srv://username:password@example.mongodb.net/test?retryWrites=true&w=majority
and I assume the "test" db name is from some old tutorial from mongo. I seem to recall thinking that was odd years ago when I first saw it.
Anyway, today, on a dev mongodb 7.0.1 cluster, there were some sporadic issues with the mongo client throwing "Authentication failed" errors periodically. Many connections were working simultaneously, but I'd say one out of every 10-20 connections was throwing this error (using the same connection string).
During troubleshooting, I copied the connection string from the mongodb atlas webapp, and noticed that the difference between the provided string and the one that I had was that the previous connection string I have used for several years had this "test" db name parameter in it:
My old connection string:
mongodb+srv://username:password@example.mongodb.net/test?retryWrites=true&w=majority
Atlas example provided connection string:
mongodb+srv://username:password@example.mongodb.net/?retryWrites=true&w=majority
Once I removed it, all of the connection failures stopped.
Any idea? Seems... strange!
Thanks
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the two MongoDB SRV connection strings in the report and review the behavior against a MongoDB 7.0.1 development cluster. Investigate whether including the /test database can cause intermittent authentication failures, then reproduce the issue or establish that the connection-string difference explains it and record the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, php
- Domain
- authentication, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100