3

I needs to use the mongo database of Rocket chat 3.0.0 using php script remotely but its not working. here is my script

$manager = new MongoDB\Client(
  'mongodb://uname:password@Ip of server:port'
);
foreach ($manager->listDatabases() as $val){
  $db_array[] = $val->getName();
}

But it gives an error like :

Uncaught exception 'MongoDB\Driver\Exception\ConnectionTimeoutException' with message 'No suitable servers found (serverSelectionTryOnce set): [connection refused calling ismaster.

So can anyone let me know the solution that how can I access the meteor mongo database of Rocket chat

PHP version = 5.6

Chetan Nakum
  • 413
  • 6
  • 19
  • Can you connect to the DB from any other remote client? – Jankapunkt Mar 05 '20 at 07:21
  • Can you please explain it ? Sorry but I didn't getting you. – Chetan Nakum Mar 05 '20 at 07:31
  • In order to reduce to the root cause we need to exclude factors that work. If you can connect to the database using a mongo client then the issue is rather in the php code. If you can't connect using any other clients the issue is likely to be your mongo auth config or your nginx config. – Jankapunkt Mar 05 '20 at 07:36
  • Yes I have tried to connect it with MongoDB compass and it works fine.I have used the SSH Tunnel : Use Password. But it doensn't work with PHP script. – Chetan Nakum Mar 05 '20 at 07:39

1 Answers1

0

Do you can connect to this Mongodb with another way? Like a Robo3T ?

  • Yes I have tried to connect it with MongoDB compass and it works fine.I have used the SSH Tunnel : Use Password. – Chetan Nakum Mar 06 '20 at 06:16
  • Try with Robo 3T, because it need more details that Mongo Compass and maybe show something good for you. –  Mar 08 '20 at 02:16