简体   繁体   English

mongodb连接被对等方重置:套接字写入器错误

[英]mongodb Connection reset by peer : socket writer error

I am receiving the error below " sometimes " during update mongodb 我在更新mongodb期间收到“ 有时 ”下面的错误

2012-03-06 00:09:39,733 SEVERE [com.mongodb.tcp] (http-0.0.0.0-80-169) MyPort.error called java.net.SocketException: Connection reset by peer: socket write error 2012-03-06 00:09:39,733严重[com.mongodb.tcp](http-0.0.0.0-80-169)名为java.net.SocketException的MyPort.error:对等重置连接:套接字写入错误

at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.bson.io.PoolOutputBuffer.pipe(PoolOutputBuffer.java:113)
at com.mongodb.OutMessage.pipe(OutMessage.java:157)
at com.mongodb.DBPort.go(DBPort.java:92)
at com.mongodb.DBPort.go(DBPort.java:66)
at com.mongodb.DBPort.say(DBPort.java:61)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:155)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:141)
at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:299)
at com.mongodb.DBCollection.update(DBCollection.java:125)
    at com.zimbra.actions.DataSave.exec(DataSave.java:46)

Let's check DataSave.java : 让我们检查一下DataSave.java:

DBCollection clDatum = com.zimbra.getSystemMongo().getCollection("datum");
BasicDBObject mySearch = new BasicDBObject();
mySearch.put("Id", 12132);
BasicDBObject myReplacement = new BasicDBObject();
myReplacement.put("$set", new BasicDBObject("A.B",
 (JSONObject) JSONValue.parse(request.getParameter("data").toString());));
// I am getting this error here (line 46):
clDatum.update(mySearch, myReplacement, true, true);

If you think I am trying to write more data than the server supplies, can you tell me where should I check? 如果您认为我要写的数据超出服务器提供的数据,您能告诉我应该在哪里检查吗? Is there any where to change this size? 有什么地方可以更改此尺寸?

Or could you pass me any idea to solve this problem ? 还是可以让我解决这个问题的任何想法?

Thanks a lot.. 非常感谢..

Probably this is because driver does not reconnect to mongodb after timeout exception, you have to handle it manually in your code. 可能是因为驱动程序在超时异常后没有重新连接到mongodb,所以您必须在代码中手动处理它。

Driver can't remove dropped socket from connection from pool until your code try use it. 驱动程序无法删除从池中删除的套接字,直到您的代码尝试使用它为止。 So in general you need try {} catch {} and repeat update twice, if second time you get error you should throw it. 因此,通常您需要try {} catch {}并重复两次更新,如果第二次遇到错误,则应将其抛出。

At least c# driver have same behavior, because it can't really control and remove dropped sockets (because they can be closed at any time), so you have to just handle it manually. 至少c#驱动程序具有相同的行为,因为它不能真正控制和删除掉落的套接字(因为它们可以随时关闭),因此您必须手动处理它。

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

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