mongodb: Remote server has closed the connection

 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 }

解决方法;失败重试

转载于:https://www.cnblogs.com/tl542475736/p/8494539.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值