2014-05-02 13:57
浏览 301

PHP / MongoDB连接超时

we're using MongoDB heavily in our web application and until recently we've had no issues at all with it. Our application see between 1000 - 2500 requests per minute but it seems that regardless of our traffic levels however we're constantly seeing a high number of the following error:

MongoConnectionException' with message 'Failed to connect to: HOST:PORT: Read timed out after reading 0 bytes, waited for 0.-01000 seconds

These appear to happen randomly. The strange part of this error is the time waited, 0.-01000 seconds, I've so far been unable to find another instance of this being documented anywhere.

The application is written in PHP and we're using the 1.4.5 version driver with version 2.4.6 of Mongo running multiple shards. The connection string is the standard mongodb://IP:PORT with no other arguments being passed.

I'm at a bit of a loss as to what might be causing this, we've not been able to find anything in the mongo logs regarding failed connection attempts and we're not hitting any connection limits at either end. Any help would be appreciated, we're likely to see a big increase in traffic over the coming months and I'd like to get this resolved before then.

Thanks in advance.

Update. Updating to the latest driver (1.5.2) solved the issue, however it required that we add in an inclusion for the JSON extension above the Mongo driver inclusion in the php.ini file otherwise we'd receive JSON not found errors.

图片转代码服务由CSDN问答提供 功能建议

我们在Web应用程序中大量使用MongoDB,直到最近我们还没有遇到任何问题。 我们的应用程序看到每分钟1000到2500个请求,但似乎无论我们的流量水平如何,我们都会经常看到大量的以下错误:

MongoConnectionException'with 消息'无法连接到:主机:端口:读取0字节后读取超时,等待0.-01000秒

这些似乎是随机发生的。 这个错误的奇怪部分是等待的时间, 0.-01000秒,到目前为止我还没有找到另外一个在任何地方记录的实例。 < p>应用程序是用PHP编写的,我们使用1.4.5版驱动程序,运行多个分片的Mongo版本2.4.6。 连接字符串是标准的 mongodb:// IP:PORT ,没有传递任何其他参数。

我有点不知道是什么 可能导致这种情况,我们无法在mongo日志中找到有关连接尝试失败的任何内容,并且我们没有在任何一端达到任何连接限制。 任何帮助将不胜感激,我们可能会看到未来几个月的流量大幅增加,我希望在此之前得到解决。


更新。 更新到最新的驱动程序(1.5.2)解决了这个问题,但是它要求我们在php.ini文件中添加Mongo驱动程序上面的JSON扩展包含,否则我们会收到JSON not found错误。 / p>

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • donglu4159 2014-05-02 14:25

    Looks to be a bug in the PHP driver version 1.4.5:


    Looks to be fixed in version 1.5.2 of the driver.

    解决 无用
    打赏 举报

相关推荐 更多相似问题