mongodb: Remote server has closed the connection

时间:2023-03-09 06:47:15
mongodb: Remote server has closed the connection
 <?php
function getMongoClient($seeds = "", $options = array(), $retry = 3) {
try {
return new MongoClient($seeds, $options);
} catch(Exception $e) {
/* Log the exception so we can look into why mongod failed later */
logException($e);
}
if ($retry > 0) {
return getMongoClient($seeds, $options, --$retry);
}
throw new Exception("I've tried several times getting MongoClient.. Is mongod really running?");
} try {
$mc = getMongoClient("localhost", array());
} catch(Exception $e) {
/* Can't connect to MongoDB! */
logException($e);
die("Can't do anything :(");
}

解决方法;失败重试