码迷,mamicode.com
首页 > 数据库 > 详细

mongodb: Remote server has closed the connection

时间:2018-03-02 20:47:26      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:exception   host   cat   post   ret   pos   time   real   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

标签:exception   host   cat   post   ret   pos   time   real   gpo   

原文地址:https://www.cnblogs.com/tl542475736/p/8494539.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!