素材牛VIP会员
python连接mongodb报错
 ma***kk  分类:Python  人气:899  回帖:2  发布于6年前 收藏
File "/home/test/publish/virtualenvs/pyv_honey_manage/lib/python2.7/site-packages/pymongo/mongo_client.py", line 1138, in _send_message
    raise AutoReconnect(str(e))
AutoReconnect: [Errno 104] Connection reset by peer

---

centos:6.5
python:2.7.8
pymongo:2.8

服务端监控看mongo客户端连接数才300左右.不知道大家遇到过类似问题吗?真的谢谢啦

讨论这个帖子(2)垃圾回帖将一律封号处理……

Lv7 码师
ph***16 JAVA开发工程师 6年前#1

更新下 pymongo 到最新,试试

Lv1 新人
何***孽 软件测试工程师 6年前#2

exception pymongo.errors.AutoReconnect(message='', errors=None)¶
Raised when a connection to the database is lost and an attempt to auto-reconnect will be made.

In order to auto-reconnect you must handle this exception, recognizing that the operation which caused it has not necessarily succeeded. Future operations will attempt to open a new connection to the database (and will continue to raise this exception until the first successful connection is made).

连接丢失需要重连时将抛出这个错误,文档中说明了,必须要手动处理这个错误.比较好的处理

处理方式

https://gist.github.com/anthonywu/1696591

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取