MongoDB连接由peer重置 [英] MongoDB connection reset by peer
问题描述
我已经看过其他解决方案,例如:
<但是仍然有这个错误。我正在尝试将一个大的GeoJSON文件加载到MongoDB中。
这是我的代码: https://gist.github.com/mittenchops/6499844
使用迭代json解析器: https://github.com/isagalaev/ijson
这是我的错误:
Traceback(最近一次调用最后一次):
文件upload2mongo.py,行57,在< module>中
main(sys.argv)
文件upload2mongo.py,第52行,在主
加载器中(renamesh2json(argv [1]),argv [2])
文件upload2mongo.py,第22行,在loader中
db [collection] .insert(d)
文件/usr/local/lib/python2.7/dist-packages/pymongo/collection.py ,第359行,插入
continue_on_error,self .__ uuid_subtype),安全)
文件/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py,第853行,在_send_message
引发AutoReconnect(str(e))
pymongo.errors.AutoReconnect:[Errno 104]连接由同行重置
为什么我收到关于我的连接关闭的这个奇怪的错误?
不确定这是答案还是有意义,但我在插入序列中添加了一个循环,并且纠正了问题。似乎我认为我插入的原始对象实际上是一个文档列表而不是文档级别,这是隐式批量插入---当我以为我实际上一次插入一个文档时,我以为我是已经在文档级别循环。
在批量插入过程中,似乎连接已关闭。
I've looked at other solutions to this, such as:
But still have this error. I'm trying to load a large GeoJSON file into MongoDB.
Here's my code: https://gist.github.com/mittenchops/6499844
using the iterative json parser here: https://github.com/isagalaev/ijson
Here is my error:
Traceback (most recent call last):
File "upload2mongo.py", line 57, in <module>
main(sys.argv)
File "upload2mongo.py", line 52, in main
loader(renamesh2json(argv[1]), argv[2])
File "upload2mongo.py", line 22, in loader
db[collection].insert(d)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 359, in insert
continue_on_error, self.__uuid_subtype), safe)
File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 853, in _send_message
raise AutoReconnect(str(e))
pymongo.errors.AutoReconnect: [Errno 104] Connection reset by peer
Why am I receiving this strange error about my connection shutting down?
Not sure if this is an answer or even makes sense, but I added one more loop in my insert sequence, and that corrected the problem. It seems that the original object I thought I was inserting was actually a list of documents instead of document-level, and this was implicitly batch-inserted---when I thought I was actually inserting one document at a time, I thought I was already looping at the document level.
It appears that over the course of the batch insert, the connection closed.
这篇关于MongoDB连接由peer重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!