mongodb: Remote server has closed the connection

Posted 闲云野鹤的博客日志

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 }

解决方法;失败重试

以上是关于mongodb: Remote server has closed the connection的主要内容,如果未能解决你的问题,请参考以下文章

$_SERVER['REMOTE_ADDR'] 可信吗? [复制]

负载均衡器 $_SERVER['REMOTE_ADDR'] 不工作

(?)企业部分之HA集群

Xen-Server 实现单点故障转移 高可用(HA)

我们可以用 php cURL 欺骗 $_SERVER['REMOTE_ADDR'] / 用户 ip 吗?

某些客户端在 $_SERVER['REMOTE_ADDR'] 中带有冒号的“垃圾”IP 地址