PHP Mongo从套接字读取错误 [英] PHP Mongo Error reading from socket

查看:61
本文介绍了PHP Mongo从套接字读取错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近两天,我的错误日志中已填充此错误:

The last couple of days, my error log has been filled with this error:

send_package: error reading from socket: The socket is closed

我真的不知道这是哪里来的.看来我的MongoDB服务器没有打开TCP套接字,但我确实只是在猜测.

I really don't know where this is coming from. It would seem that my MongoDB server is not opening the TCP socket, but I really am just guessing.

有没有人以前见过此错误或知道如何处理?

Has anyone seen this error before or know how to handle it?

产生错误的行是:

$mongo = new Mongo("mongodb://user:pwd@host/db",array('timeout'=>6000));

我偶尔也会从Pimple DIC进来

I'm also occasionally getting in from within the Pimple DIC:

    class HurstDI extends \Pimple
    {
        public function __construct(){
            $this['mongoUser'] = 'user';
            $this['mongoPwd'] = 'pwd';
            $this['mongoHost'] = "host/db";
            $this['mongoTimeout'] = 6000;
            $this['mongodb'] = function($c){
            return new \MongoClient("mongodb://{$c['mongoUser']}:{$c['mongoPwd']}@{$c['mongoHost']}");
        };
    }
    }

推荐答案

存在已知问题使用PHP/mongoclient + Apache + MongoDB,其中无效的持久连接由Apache进程保持打开状态.

There is a known issue with PHP/mongoclient + Apache + MongoDB where invalid persistent connections are held open by the Apache process.

尝试重新启动Apache Web服务器.

Try to restart your Apache web server.

会发生什么:

  • 在正常请求期间,Apache将打开与您的MongoDB服务器的连接.
  • 大概是在某个时候,您已经重新启动了MongoDB服务器
  • Apache/PHP从不认识到MongoDB重新启动期间该连接已关闭,并保持先前​​打开的持久连接

解决此问题的唯一方法是重新启动Apache(迫使它杀死所有工作线程并创建新连接).

The only way to get past this issue is to restart Apache (forcing it to kill all of the worker threads and create new connections).

让我知道这是否对您有用.

Let me know if this works for you.

这篇关于PHP Mongo从套接字读取错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆