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的更多相关文章

  1. Request Connection: Remote Server @ 192.229.145.200:80

    录制Loadrunner脚本时,提示: Request Connection: Remote Server @ 192.229.145.200:80   NOT INTERCEPTED!(REASON ...

  2. 解决loadrunner录制时 Request Connection: Remote Server @ 0.0.0.0:80 (Service=?) NOT PROXIED! (REASON: Unable to connect to remote server: rc = -1 , le = 0)问题

    环境为win7+ie8+loadrunner11,录制脚本回放查看Recoding log 出现如下错误:[Net An. Error    ( 7f8:1340)] Request Connecti ...

  3. AMQP server localhost:5672 closed the connection. Check login credentials: Socket closed

    2016-04-13 09:23:38.755 18850 INFO oslo.messaging._drivers.impl_rabbit [req-fafc8542-9403-4b5a-89d2- ...

  4. lr11录制时报“Request Connection: Remote Server @ 0.0.0.0:1080 (Service=?) NOT PROXIED! )”解决方法

    在录制脚本的时候出现如下现象: 解决方法: LoadRunner录制脚本时出现:Unable to connect to remote server),有事件没有脚本的问题   1.首先要查看IE浏览 ...

  5. org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or br

    WARN <init>, HHH000409: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF R ...

  6. Golang : Forwarding a local port to a remote server example

    原文:https://socketloop.com/tutorials/golang-forwarding-a-local-port-to-a-remote-server-example 端口转发, ...

  7. 【API管理 APIM】APIM集成内部VNet后,自我访问出现(Unable to connect to the remote server)问题,而Remote Server正是APIM它自己

    问题描述 在使用APIM配置内部VNET后,如API-1正常配置访问后端服务器的一个接口,而API-2则是通过调用APIM中的API-1来作为backendUrl,会出现500错误. 经过测试,目前这 ...

  8. selenium Remote Server 实现原理

    selenium作为一个出色的web automation框架,被越来越多的企业采用究其原因,框架设计的比较remarkable, 作为一个开源的框架,能够开辟出一套协议,以至于针对app测试的app ...

  9. CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

    今天,在用icinga服务器端测试客户端脚本时,报如下错误: [root@mysql-server1 etc]# /usr/local/icinga/libexec/check_nrpe -H 192 ...

随机推荐

  1. window对象的属性

    还不是很了解,以后补充frames      opener       parent

  2. 创建分模块的maven项目

    折腾了我2天的maven,整理一下,以后做个参考 一.什么是maven项目: Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具. Maven ...

  3. 深入理解JAVA虚拟机之JVM性能篇---垃圾回收

    一.基本垃圾回收算法 1. 判断对象是否需要回收的方法(如何判断垃圾): 1) 引用计数(Reference Counting)  对象增加一个引用,即增加一个计数,删除一个引用则减少一个计数.垃圾回 ...

  4. java之过滤器Filter

    Java三大器之过滤器(Filter)的工作原理和代码演示   一.Filter简介 Filter也称之为过滤器,它是Servlet技术中最激动人心的技术之一,WEB开发人员通过Filter技术,对w ...

  5. WEB消息推送-框架篇

    WEB消息推送-comet4j 一.comet简介: comet :基于 HTTP长连接的“服务器推”技术,是一种新的 Web 应用架构.基于这种架构开发的应用中,服务器端会主动以异步的方式向客户端程 ...

  6. configparser模块的常见用法

    configparser模块用于生成与windows.ini文件类似格式的配置文件,可以包含一节或多节(section),每个节可以有一个或多个参数(键=值) 在学习这个模块之前,先来看一个经常见到的 ...

  7. git指令总结

    在学习flask之前,先汇总一下Git的指令. mkdir filedir 创建文件夹filedir cd filedir 进入文件夹 pwd 显示当前工作目录 git init 初始化git仓库 g ...

  8. Python基础篇(八)

    key words:私有变量,类静态变量,生成器,导入Python模块,r查看模块可以使用的函数,查看帮助信息,启动外部程序,集合,堆,时间模块,random模块,shelve模块,文件读取等 > ...

  9. JAVA 二进制基础

    主要内容 1.十进制二进制互转 2.二进制的位运算 3.JDK内置的进制转换 4.JAVA中的进制 十进制二进制互转 57 111001 二进制的位运算:优点:特定情况下,计算方便,被支持面广泛. ① ...

  10. centos 7 配置 到多站点设置

    背景 : 前面配置了 win2008 WAMP环境, 这次因为一些事情 新买了服务器  只有 win2003 和 win2012, 试着配置2012 WAMP环境 发现比 2008 缺的配置文件多很多 ...