Laravel mongodb closing client connection remaining data is too small

Route::get('/', function () { $tweets = Tweet::all(); return view('welcome', ['tweets' => $tweets]); }); 

I am making a laravel application using mongodb.

When I go to '/', I get an error in the mongod terminal that says

 AssertionException handling request, closing client connection: 10304 Client Error: Remaining data too small for BSON object 

This is my tweet model (in \ Tweet app):

 namespace App; use Jenssegers\Mongodb\Model as Eloquent; class Tweet extends Eloquent { protected $collection = 'tweets_collection'; } 
+5
source share
2 answers

At least two reasons why this problem occurs ( Client Error: Remaining data too small for BSON object ):

1. The MongoDB PHP driver is not compatible with MongoDB installed on the machine.
(originally mentioned in the first answer ).

Examine the version of the PHP driver installed on your computer at <?php phpinfo(); :

enter image description here

Extract the MongoDB version using:

 mongod --version\ # db version v3.2.0 

Use the compatibility table on the MongoDB website to find out if the version of the PHP driver MongoDB is compatible with the version of MongoDB:

enter image description here

If the versions are incompatible, you must remove one of the existing parts and install a compatible version. From my own experience, it’s much easier to change the PHP MongoDB driver, since only another .so extension file is required.

2. Two PHP MongoDB drivers are installed on the machine.

Since MongoClient deprecated, many tutorials and articles on the Internet (including the official mongo-php driver repository on Github ) now contain instructions for installing the mongodb driver, not mongo PHP. A year + earlier, everyone pointed to the mongo extension.

Due to this change from mongo to mongodb we can get both extensions defined in the php.ini . Just make sure that only one extension is defined in the "Dynamic Extension" section:

enter image description here


I hope someone gets this answer when looking for a solution to fix the error "The rest of the data is too small for the BSON object" working with MongoDB through PHP MongoDB.

+1
source

The problem was that Laravel was unable to contact MongoDB because I used the php mongodb-1.1 driver and MongoDB 3.2 together. According to the table found on this page: https://docs.mongodb.org/ecosystem/drivers/php/ , these two versions are incompatible. I uninstalled MongoDB 3.2 and installed MongoDB 3.O and the problem was resolved.

0
source

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


All Articles