首页 > 解决方案 > (PHP + MongoDB + Laravel jenssegers)无法向数据库发送“count”命令:套接字错误或超时

问题描述

自 2019 年以来,我一直在我的 Amazon 中运行 MongoDB。它拥有超过数百万的数据,并且直到昨天都运行良好。但是今天当我尝试使用 Laravel jenssegers eloquent 模型进行查询时,它给了我这个错误:

Failed to send "count" command with database "<database>": socket error or timeout

at /var/www/html/console/vendor/mongodb/mongodb/src/Operation/Count.php:154
150| if (isset($this->options['readConcern']) && ! \MongoDB\server_supports_feature($server, self::$wireVersionForReadConcern)) {
151| throw UnsupportedException::readConcernNotSupported();
152| }
153|

154| $cursor = $server->executeReadCommand($this->databaseName, new Command($this->createCommandDocument()), $this->createOptions());
155| $result = current($cursor->toArray());
156|
157| // Older server versions may return a float
158| if ( ! isset($result->n) || ! (is_integer($result->n) || is_float($result->n))) {

Exception trace:

1 MongoDB\Driver\Server::executeReadCommand("dddb", Object(MongoDB\Driver\Command), [Object(MongoDB\Driver\ReadPreference)])
/var/www/html/console/vendor/mongodb/mongodb/src/Operation/Count.php:154

2 MongoDB\Operation\Count::execute(Object(MongoDB\Driver\Server))
/var/www/html/console/vendor/mongodb/mongodb/src/Collection.php:277

Please use the argument -v to see more details.

标签: phplaravelmongodb

解决方案


推荐阅读