Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AggregateCursor issue with MongoDB 3.6

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?

like image 222
DanieleVT Avatar asked Jan 29 '23 03:01

DanieleVT


1 Answers

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

like image 151
DanieleVT Avatar answered Jan 31 '23 20:01

DanieleVT