MongoCursorException 'could not get response header'

I am developing a website using PHP and mongodb. I turn to mongodb with pecl -mongo and stumbled upon annoyance. From time to time I get this error (I anonymized the paths)

Fatal error: Uncaught exception 'MongoCursorException' with message 'couldn't get response header' in /PATH/index.php:38 Stack trace: #0 /PATH/index.php(38): MongoCursor->rewind() #1 /PATH/template.inc(29): get_sidebar() #2 /PATH/index.php(13): require_once('PATH/...') #3 {main} thrown in PATH/index.php on line 38 

According to the documentation, this means:

The driver could not get the response header from the database, so it gives up. Check if the database is still not on the network and try the query again.

But I know that the database works because I do it locally on my machine through loopback. In the outside world there is no connection.

Just trying again often works. Perhaps this is a bug in the mongo PHP driver? Could this be a "mistake" problem (I compiled from the source, but with very soft flags, -march=native -O2 )?

Has anyone seen this before?

Search around, I see only links to some dumb facebook game with the same error.

EDIT . I just downgraded my PECL driver to version 1.1.4 and so far , the problem seems to be gone. So this may just be a mistake in the 1.2.x series. If someone can shed light on this, it will be great.

EDIT : here I am not doing anything complicated, the code that has the problem is as follows:

 $m = new Mongo(); $collection = $m->my_db->collection; $results = $collection->find(array("favorite"=>true))->limit(5); 
+6
source share
1 answer

I solved this problem get a new version of mogodb.dll you can see http://www.mongodb.org/display/DOCS/PHP+Language+Center

+1
source

Source: https://habr.com/ru/post/893895/


All Articles