AggregateCursor issue with MongoDB 3.6

给你一囗甜甜゛ 提交于 2020-08-02 17:54:10

问题


I've updated my MongoDB to the 3.6 version. I'm using a PHP MongoClient on CentOS 7 and PHP 5.5.38. If I run the aggregateCursor method of the MongoDB library, through the first example reported in http://php.net/manual/en/mongocollection.aggregatecursor.php, I obtain the following error message as below:

PHP Fatal error:  Uncaught exception 'MongoCursorException' with message '95.110.150.99:27017: the command cursor did not return a correctly structured response' 

Do you have any idea about this behaviour?


回答1:


The problem was in the cursor id returned by Mongo:

 ["id"]=>
    float(6.43105103109E+18)

To build the MongoCommandCursor object, the id is expected to be a MongoInt64:

["id"]=>
    object(MongoInt64)#5 (1) {
      ["value"]=>
      string(12) "392143983421"
    }

It can be done by setting:

ini_set('mongo.native_long', false);
ini_set('mongo.long_as_object', true);

The problem is described in details at: https://derickrethans.nl/64bit-ints-in-mongodb.html



来源:https://stackoverflow.com/questions/47569871/aggregatecursor-issue-with-mongodb-3-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!