0

Connecting to the mongodb atlas and trying to write a simple document gives the following error. What am I doing wrong?

$manager = new MongoDB\Driver\Manager("mongodb://admin:admin@test-shard-00-00-rbgc.mongodb.net:27017/db?ssl=false&replicaSet=test-shard-0&authSource=admin&serverSelectionTryOnce=false");

var_dump($manager);

$bulk = new MongoDB\Driver\BulkWrite;

$bulk->insert(['x' => 1]);
$manager->executeBulkWrite('db.collection', $bulk);

Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found: serverselectiontimeoutms timed out: [connection closed calling ismaster on 'test-shard-00-00-waf4c.mongodb.net:27017'] in /Applications/AMPPS/www/mongodb/liveserver.php:63

When I var_dump the $manager I get:

object(MongoDB\Driver\Manager)#1 (2) { ["uri"]=> string(64) "admin:admin@test-shard-00-00-rbgc.mongodb.net:27017/" ["cluster"]=> array(0) { } }

  • You can not access `test-shard-00-00-rbgc.mongodb.net:27017` so it is either the wrong name/port or you have some network issue that prevents you from going from your server to this endpoint. – Patrick Mevzek Jun 26 '18 at 17:10

0 Answers0