Closed tw0325795 closed 4 years ago
Hi @tw0325795, I think you are trying to connect with MongoDBAtlas.
Does your password contains "@" or other symbols? They conflict in the dsn parsing on MongoPHP Driver. Try to change the password with one that only contains number and letter.
Moreover you have to change test
mongodb+srv://xxxxxxxx:xxxxxxxxx@xxxxxx-xxxx.mongodb.net/test?retryWrites=true&w=majority
with the name of your database env('DB_DATABASE')
Has anyone been able to get this to work? I can't seem to connect using the following config:
[
"driver" => "mongodb",
"dsn" => "mongodb+srv://username:password@companyname-xxxx.mongodb.net/database-production?retryWrites=true&w=majority",
"database" => "database-production",
"options" => [
"database" => "database-production",
"ssl" => true,
],
]
The error message I receive is:
No suitable servers found (`serverSelectionTryOnce` set): [Failed to receive length header from server. calling ismaster on 'companyname-shard-xxxxxxx.mongodb.net:27017'] [Failed to receive length header from server. calling ismaster on 'companyname-shard-xxxxx.mongodb.net:27017']
I'm using PHP 7.2 and MongoDB-1.7.0. Thanks!
@whobutsb did you able to solve the issue? I'm getting same errors.
Hi The issue is solved. Remember never to add "@" in the password or username of cluster. This will resolve "Failed to look up SRV record " error.
Then I got this error "No suitable servers found (serverSelectionTryOnce
set)". As I created and use a connection string from another project/cluster with password containing only albhabet and number.
So, I solved it by using the previous connection string but with edited password.
I solved the issue
Glad this has been resolved.
Closing.
I meet an issue of mongodb.atlas I used +srv connect to my cluster But I get this error
MongoDB\Driver\Exception\ConnectionTimeoutException: Failed to look up SRV record "_mongodb._tcp.xxxxxxxxx-xxxxx.mongodb.net": Operation not permitted in file /home/vagrant/Code/xxxxxxxx/vendor/mongodb/mongodb/src/Collection.php on line 866
My mongodb is Version 4.0.13 My controllerMy database.php
My .env
How can I do?