MongoCursorTimeoutException in jenssegers/laravel-mongodb MongoCursorTimeoutException in jenssegers/laravel-mongodb mongodb mongodb

MongoCursorTimeoutException in jenssegers/laravel-mongodb


There is an issue PHP-1249 - MongoCursor::count() should use cursor's socket timeout submitted for PHP MongoDB driver v1.5.7 which was fixed in v1.5.8 in October, 2014.

The reply from the support:

Looking into the code a bit, it appears that both socket timeout and maxTimeMS is not passed along to the count command.

If you need an immediate work-around, you should be able to get by with MongoDB::command() for now (which can support both timeouts).

The workaround posted by one of the users is:

$countComand = $mongo->command(    array(        'count' => 'collection',        'query' => $query    ),    array('socketTimeoutMS' => -1)); if($countComand['ok']){    $count = $countComand['n'];} else {    // ... error ...}

It seems that laravel-mongodb doesn't use MongoDB::command(). You either have to write your query explicitly without help of where methods as shown above or upgrade to v.1.5.8.