Closed yunier0525 closed 4 years ago
Hi!
Are you using Documentdb?
Thanks!
Hi,
Yes, I am using DocumentDB, but I ask the question because in MongoDB you can also configure SSL, so in that case how would I do it?
Thanks!
Hi,
Now I disabled the TLS option on DocumentDB, and I get this results:
Command: Works fine
mongo "mongodb://user:pass@host.com:27017/db"
PHP code: Work fine
$client = new MongoDB\Client('mongodb://user:pass@host.com:27017/db');
var_dump( $client->test);
MongoDB\Database {#4960
databaseName: "test",
manager: MongoDB\Driver\Manager {#4968},
readConcern: MongoDB\Driver\ReadConcern {#4963},
readPreference: MongoDB\Driver\ReadPreference {#4973
+"mode": "primary",
},
typeMap: [
"array" => "MongoDB\Model\BSONArray",
"document" => "MongoDB\Model\BSONDocument",
"root" => "MongoDB\Model\BSONDocument",
],
writeConcern: MongoDB\Driver\WriteConcern {#4956},
}
MongoDB Compass: Works fine
Laravel with laravel-mongodb: Don't work Error: Exception Message:↵↵Authorization failure Config: database.php
'mongodb' =>
[
'driver' => 'mongodb',
'dsn' => env('MONGO_DB_DSN'),
'database' => env('MONGO_DB_DATABASE', 'db'),
]
.env
MONGO_DB_DSN=mongodb://user:pass@host.com:27017/db
MONGO_DB_DATABASE=db
@yunier0525, Why do you use MONGO_DB_DATABASE=develop
but database in MONGO_DB_DSN
is db ?
@yunier0525, Why do you use
MONGO_DB_DATABASE=develop
but database inMONGO_DB_DSN
is db ?
Is dummy data, in my code the two values are the same. I'm updated the comment with de name of db.
Hi,
Yes, I am using DocumentDB, but I ask the question because in MongoDB you can also configure SSL, so in that case how would I do it?
Thanks!
You've got an answer from me here https://github.com/jenssegers/laravel-mongodb/issues/2074, not sure why are you trying to ask same questions twice.
SSL option works with MongoDB but there are some problems with DocumentDB compatibility.
Please check this issue for possible solutions https://github.com/jenssegers/laravel-mongodb/issues/1709
Hi @divine ,
I opened this question again cause I read every comment to this respect and I can't find a correct answer. I apologize to duplicate the question, but you close the issue assuming that the problem is resolved in others comments.
If you tell me DocumentDB is not compatible with laravel-mongodb ok, but give me a clear answer.
I think laravel-mongodb have a issue here, you decide if you wanna see the problem.
Regards.
Hi @divine ,
I opened this question again cause I read every comment to this respect and I can't find a correct answer. I apologize to duplicate the question, but you close the issue assuming that the problem is resolved in others comments.
If you tell me DocumentDB is not compatible with laravel-mongodb ok, but give me a clear answer.
I think laravel-mongodb have a issue here, you decide if you wanna see the problem.
Regards.
It's already an open issue here https://github.com/jenssegers/laravel-mongodb/issues/1709 , there is no reason to create multiple new issues when there is one open.
See this for clarification regarding compatibility https://www.mongodb.com/atlas-vs-amazon-documentdb
@yunier0525, call this code and attach dump here, please
$client = new MongoDB\Client('mongodb://user:pass@host.com:27017/db');
$collection = $client->test->test_collection;
$result = $collection->insertOne( [ 'name' => 'Test #2'] );
$result = $collection->find( [ 'name' => 'Test #2' ] );
var_dump($result);
@Smolevich
I get this error
MongoDB/Driver/Exception/BulkWriteException with message 'Authorization failure'
on
$result = $collection->insertOne( [ 'name' => 'Test #2'] );
It seems to be a DB user permission issue.
Thanks
Hi, I was able to successfully connect to AWS DocumentDB even with the certificates, in the end it was all permission issue.
I leave my final configuration as it was: database.php
'mongodb' => [ 'driver' => 'mongodb', 'dsn' => env('MONGO_DB_DSN'), 'database' => env('MONGO_DB_DATABASE', 'db'), 'options' => [ 'tls' => true, 'tlsCAFile' => '/var/www/.ssh/mongodb-certificate-develop.pem' ], ] .env
MONGO_DB_DSN=mongodb://user:pass@host.com:27017/db MONGO_DB_DATABASE=db
Thank you very much
Hi,
I have this command line that works fine:
/# mongo --tls "mongodb://user:pass@host.com:27017/db" --tlsCAFile /var/www/.ssh/mongodb-certificate-develop.pem
The problem is when I try to setup the same config on laravel. With this config, I get "Exception Message:↵↵Authorization failure", after many tries I know that the problems is with ssl configuration.
database.php
.env
I read many comments with this respect but I can't find a solution.
What is the correct way to config ssl certificate ?