1
我正在用codeigniter构建PHP应用程序,并使用GAE与Mongodb。 GAE是计费启用,但到蒙戈连接不稳定,降至1/4时,应用程序在线,本地正常工作与GAE PHP SDK:GAE PHP与mongodb失去连接
的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);
但这显然不是你的代码的问题。你会得到一个可以正常工作的连接,并且在你的代码中没有任何东西说'在第三次调用这个URL时失败....'。 –
我有一个快速的样子 - 似乎是mongo客户端的一个问题,以及它如何回收套接字描述符。您有可能在我们的问题跟踪器中提交错误吗? https://code.google.com/p/googleappengine/wiki/FilingIssues?tm=3 –
GAE很有可能使用的是较旧的“mongo.so”驱动程序扩展,该驱动程序已知具有类似的连接丢失问题与更新的MongoDB服务器。 http://stackoverflow.com/questions/22947873/failed-to-connect-to-localhost27017-remote-server-has-closed-the-connection – Visar