04 March 2013

mongodb & PHP: Uncaught exception 'MongoConnectionException' with message 'No candidate servers found'

While playing with mongodb, i got the following error in PHP:
2013/03/04 16:47:27 [error] 1399#0: *376172 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 'No candidate servers found' in /not/relevant/mongoDB.php:28
Stack trace:
#0 /not/relevant/mongoDB.php(28): Mongo->__construct('mongodb://10.0....', Array)
#1 /not/relevant.php(46): Mongo_DB->connect(Array)
#2 /not/relevant/index.php(63): API->__construct('json/notificati...')
#3 {main}
thrown in /not/relevant/mongoDB.php on line 28" while reading response header from upstream, client:, server: not_relevant.com, request: "POST /json/ HTTP/1.0", upstream: "fastcgi://unix:///tmp/php.sock:", host: "", referrer: "http://not_relevant.com"

To fix it, check the following:
1. You don't use localhost/ as a node in your cluster
2. You have the right IPs in the connect to replica field. Check this again.
3. You are using the MongoClient::RP_SECONDARY_PREFERRED and not the MongoClient::RP_SECONDARY
4. Check google, I'm out of ideas. The above helped me.

No comments:

Post a Comment