通过 PHP 连接到 MongoDB 时出现最大限制大小错误
When connecting to MongoDB via PHP maximum limit size error appears
我正在尝试使用此 PHP 代码连接到远程服务器:
if ($mongo = new MongoClient('mongodb://root:password#@111.111.111.11:2222'))
if ($db = $mongo->selectDB("test"))
Fatal error: Uncaught exception 'MongoConnectionException' with
message 'Failed to connect to: 111.111.111.11:2222: send_package: data
corruption: the returned size of the reply (759714607) is larger than
the maximum allowed size (4194304)' in
/var/www/html/mongo/index.php:24 Stack trace: #0
/var/www/html/mongo/index.php(24):
MongoClient->__construct('mongodb://root:...') #1 {main} thrown in
/var/www/html/mongo/index.php on line 24
我使用这个命令创建了 ssh 隧道:
autossh -C -p 22 -l {name}
-N -o ConnectTimeout=5 -o TCPKeepAlive=yes -o
NumberOfPasswordPrompts=3 -o ControlMaster=no -o
PreferredAuthentications=password -L 27018:localhost:27017
root@420.213.412.21
它基本上在我的本地计算机和带有数据库的服务器之间创建了 ssh 连接隧道。打开端口为 27018,结束端口为 27017,即 MongoDB 端口。
然后对于代码中的连接参数,我使用了这个:
$mongo = new MongoClient('localhost:27018');
正在连接到 ssh 隧道的开放端口。
我正在尝试使用此 PHP 代码连接到远程服务器:
if ($mongo = new MongoClient('mongodb://root:password#@111.111.111.11:2222'))
if ($db = $mongo->selectDB("test"))
Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: 111.111.111.11:2222: send_package: data corruption: the returned size of the reply (759714607) is larger than the maximum allowed size (4194304)' in /var/www/html/mongo/index.php:24 Stack trace: #0 /var/www/html/mongo/index.php(24): MongoClient->__construct('mongodb://root:...') #1 {main} thrown in /var/www/html/mongo/index.php on line 24
我使用这个命令创建了 ssh 隧道:
autossh -C -p 22 -l
{name}
-N -o ConnectTimeout=5 -o TCPKeepAlive=yes -o NumberOfPasswordPrompts=3 -o ControlMaster=no -o PreferredAuthentications=password -L 27018:localhost:27017 root@420.213.412.21
它基本上在我的本地计算机和带有数据库的服务器之间创建了 ssh 连接隧道。打开端口为 27018,结束端口为 27017,即 MongoDB 端口。
然后对于代码中的连接参数,我使用了这个:
$mongo = new MongoClient('localhost:27018');
正在连接到 ssh 隧道的开放端口。