简体   繁体   English

Mongodb:对等方重置连接

[英]Mongodb: Connection reset by peer

I have a Mongo server running on an Ubuntu box, and I am trying to connect to it with pymongo using the usual syntax:我有一个在 Ubuntu 机器上运行的 Mongo 服务器,我正在尝试使用 pymongo 使用通常的语法连接到它:

from pymongo import Connection
c = Connection('db.example.com', 27017)

This works just fine on a recent-model Intel mac (OS 10.6).这在最新型号的 Intel mac (OS 10.6) 上运行良好。 However, the same code on an older G5 tower (10.5) throws this error:但是,旧 G5 塔 (10.5) 上的相同代码会引发此错误:

pymongo.errors.AutoReconnect: [Errno 54] Connection reset by peer

The mongo output on the server reports:服务器上的 mongo 输出报告:

connection accepted from oldmac.example:57681 #3
bad recv() len: 973078528
end connection oldmac.example:57681

I know that I cannot run the mongodb server from the PPC Mac, but it seems odd that I wouldn't be able to connect to the remote database.我知道我无法从 PPC Mac 运行 mongodb 服务器,但我无法连接到远程数据库似乎很奇怪。 Or is something else at fault?还是有其他问题?

Looks like Mike Dirolf already answered your question in the MongoDB Google Group.看起来 Mike Dirolf 已经在 MongoDB Google Group 中回答了您的问题。 But for people experiencing the same issue and find themselves on this page, the solution from Mike Dirolf:但是对于遇到相同问题并在此页面上发现自己的人,Mike Dirolf 的解决方案:

Are you using the C extension?您使用的是 C 扩展名吗? (try pymongo.has_c()). (试试 pymongo.has_c())。 I wouldn't think that the C extension would even build on PPC but if it did that is almost certainly the reason this isn't working.我不认为 C 扩展甚至会建立在 PPC 上,但如果确实如此,几乎可以肯定这是它不起作用的原因。 You can install w/o C with python setup.py install --no_ext and then I'd expect things to work.您可以使用python setup.py install --no_ext安装 w/o C,然后我希望一切正常。

-- Mike Dirolf ——迈克·迪罗夫

I was able to solve this same issue by using MongoClient instead of the deprecated Connection .我能够通过使用MongoClient而不是已弃用的Connection来解决同样的问题。

From the Python driver for MongoDB page来自MongoDB页面的Python 驱动程序

Warning DEPRECATED: Connection is deprecated.警告已弃用:不推荐使用连接。 Please use MongoClient instead.请改用 MongoClient。

For more information, see the new MongoClient documentation for Python.有关更多信息,请参阅 Python 的新MongoClient 文档

I was facing the same issue with python3.8 , i tried to upgrade and downgrade the pymongo but the result was same Connection reset by peer .我在使用python3.8 时遇到了同样的问题,我尝试升级和降级 pymongo,但结果是相同的Connection 被 peer 重置

To overcome this problem uninstall the python3.8 and install python3.7 and it work fine.为了解决这个问题,卸载python3.8并安装python3.7 ,它工作正常。 Now i am able to connect to the mongodb and able to perform query.现在我能够连接到 mongodb 并能够执行查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM