0

I am trying to connect with options parameter but it does not connect

try
  { 
    $connection_url = "mongodb://{$dbuser}:{$dbpass}@{$dburl}:{$dbport}/{$dbname}";
    $m = new MongoClient($connection_url, 
                          array('connectTimeoutMS'=>30000,
                                'socketTimeoutMS'=>30000)
                       );

   }
   catch ( MongoConnectionException $e ) 
   {
     echo $e->getMessage();

   }
   catch ( MongoException $e ) 
   {
     echo $e->getMessage();
   } 
   catch ( Exception $e ) 
   {
     echo $e->getMessage();
   }

this code simply goes to exception with no message.

If I remove options parameters it makes a connection to mongodb server.

Why it does not connect with parameter option?

If I use another way to pass options parameter

$connection_url = "mongodb://{$dbuser}:{$dbpass}@{$dburl}:{$dbport}
                 /{$dbname}?connectTimeoutMS=30000&socketTimeoutMS=30000";
$m = new MongoClient($connection_url);

It through error

'MongoConnectionException' with message '- Found unknown connection string option 'connectTimeoutMS' with value '>30000''

Neither way is working with options parameter.

Mongodb is on mongohq.com

Shakti Singh
  • 84,385
  • 21
  • 134
  • 153

1 Answers1

0

This is actually documented as not supported in the PHP manual page for MongoClient.

Also as mentioned in the ChangeLog at the bottom of the page, support for the options (option argument style) for the options you are using was only added at version 1.3.4 of the driver. So you may need to check your driver version.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
  • my driver version is up to date. It is 1.4.5 – Shakti Singh Feb 22 '14 at 11:21
  • @ShaktiSingh Then this does seem unusual as I have tested this myself. The error given would be emitted from the PHP driver on options checking. It is not thrown from an external source. – Neil Lunn Feb 22 '14 at 11:25