Code:
try {
$documentsFind = $client->$db->$collection->find([
// query
]);
if ($documentsFind) {
foreach ($documentsFind as $product) {
// code...
}
}
catch (MongoCursorException $e) {
echo "error message: ".$e->getMessage()."\n";
echo "error code: ".$e->getCode()."\n";
}
Error:
Fatal error: Uncaught MongoDB\Driver\Exception\RuntimeException: Cursor not found, cursor id: 31837896248 in ...
It seems that the cursor does exist but times out? How can I prevent that from happening?
Edited to add: I tried doing:
if ($documentsFind) {
$documentsFind->immortal(true); // keep alive
foreach ($documentsFind as $product) {
// code...
}
}
But that results in Call to undefined method MongoDB\Driver\Cursor::immortal()
.
mongod --setParameter cursorTimeoutMillis=9000000
– Sevenfold