【问题标题】:GAE PHP Lose connection with mongodbGAE PHP 失去与 mongodb 的连接
【发布时间】:2016-03-03 22:56:19
【问题描述】:

我正在使用 codeigniter 构建 PHP 应用程序,并将 GAE 与 Mongodb 一起使用。 GAE 已启用计费,但与 mongo 的连接不稳定,应用在线时会掉线 1/4,本地与 GAE PHP SDK 配合使用正常:

php.ini

google_app_engine.enable_functions = "libxml_disable_entity_loader"
google_app_engine.enable_curl_lite = “1”

extension="mongo.so" 

mongo_library.php

try {
    //connect to the mongodb server
    SELF::$mongo_client = new MongoClient($config_data['mongo_connection_string']);

    //select the mongodb database
    $this->db = SELF::$mongo_client->selectDB($config_data['mongo_database']);

} catch (MongoConnectionException $exception) {
     //if mongodb is not connect, then display the error
     show_error('Unable to connect to Database', 500);
}

我正在使用来自 mongolab.com 谷歌云提供商的 mongo 免费计划。 这是显示My app 的链接,您可以通过刷新几次来查看它是如何失败的。

$a = mongo_db::$mongo_client;

$connections = $a->getConnections();

print_r($connections);

【问题讨论】:

  • 但这显然不是您的代码的问题。您获得了一个有效的连接,并且您的代码中没有任何内容显示on the third call to this url fail....
  • 我快速浏览了一下 - 似乎是 mongo 客户端中的一个问题,以及它如何回收套接字描述符。您可以在我们的问题跟踪器中提交错误吗? code.google.com/p/googleappengine/wiki/FilingIssues?tm=3
  • GAE 很可能使用的是较旧的“mongo.so”驱动程序扩展,已知该扩展与较新的 MongoDB 服务器存在类似的连接中断问题。 stackoverflow.com/questions/22947873/…
  • 链接中的第二个答案也与您的代码无关,因为您已经在使用新的 MongoClient,所以我认为第一个答案与您遇到的相同问题有关
  • 嗨,我有 Lumen 项目,我想在 App Enginge 上托管,并希望将它与 mongolab 连接。我找不到解决方案说 Class 'MongoDB\Driver\Manager' not found 。你能指导我如何安装它吗?

标签: php mongodb google-app-engine mlab


【解决方案1】:

这是我打开的问题:

https://code.google.com/p/googleappengine/issues/detail?id=12392

这个问题/错误已经修复。

【讨论】:

    猜你喜欢
    • 2013-05-20
    • 2015-07-29
    • 2023-03-23
    • 2015-12-31
    • 2019-03-03
    • 2012-08-31
    • 1970-01-01
    • 2017-06-02
    • 2012-05-11
    相关资源
    最近更新 更多