1. 程式人生 > >mongodb: Remote server has closed the connection

mongodb: Remote server has closed the connection

host func row fun can why remote nec gpo

 1 <?php
 2 function getMongoClient($seeds = "", $options = array(), $retry = 3) {
 3     try {
 4         return new MongoClient($seeds, $options);
 5     } catch(Exception $e) {
 6         /* Log the exception so we can look into why mongod failed later */
 7         logException($e);
 8     }
 9
if ($retry > 0) { 10 return getMongoClient($seeds, $options, --$retry); 11 } 12 throw new Exception("I‘ve tried several times getting MongoClient.. Is mongod really running?"); 13 } 14 15 try { 16 $mc = getMongoClient("localhost", array()); 17 } catch(Exception $e) { 18 /*
Can‘t connect to MongoDB! */ 19 logException($e); 20 die("Can‘t do anything :("); 21 }

解決方法;失敗重試

mongodb: Remote server has closed the connection