com.mongodb.MongoException $ Network引起:java.net.SocketTimeoutException:读取超时

时间:2014-01-24 06:27:00

标签: java mongodb morphia

当我使用morphia将文档插入Mongo-DB时,总是会出现com.mongodb.MongoException $ Network:对服务器异常执行写操作,可能是一分钟的间隔 以下是堆栈信息:

com.mongodb.MongoException$Network: Write operation to server
    at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:153)
    at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:115)
    at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:327)
    at com.mongodb.DBCollection.update(DBCollection.java:178)
    at com.mongodb.DBCollection.save(DBCollection.java:818)
    at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:882)
    at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:949)
    at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:934)
    at com.yeahmobi.datasystem.conversion.datarepository.mongodb.MongoTransmappingRepository.insert(MongoTransmappingRepository.java:36)
    at com.yeahmobi.datasystem.conversion.datarepository.merge.MergeTransmappingRepository.insert(MergeTransmappingRepository.java:24)
    at com.yeahmobi.datasystem.conversion.threads.JumpInserter.saveJumpLog(JumpInserter.java:134)
    at com.yeahmobi.datasystem.conversion.threads.JumpInserter.run(JumpInserter.java:163)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
    at org.bson.io.Bits.readFully(Bits.java:46)
    at org.bson.io.Bits.readFully(Bits.java:33)
    at org.bson.io.Bits.readFully(Bits.java:28)
    at com.mongodb.Response.<init>(Response.java:40)
    at com.mongodb.DBPort.go(DBPort.java:142)
    at com.mongodb.DBPort.go(DBPort.java:106)
    at com.mongodb.DBPort.findOne(DBPort.java:162)
    at com.mongodb.DBPort.runCommand(DBPort.java:170)
    at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:100)
    at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:142)

有没有人遇到同样的问题?任何建议都值得赞赏。

由于

1 个答案:

答案 0 :(得分:2)

这是不寻常的,在正常操作期间不应经常发生。

尝试从网络/操作系统的角度进行调试,请检查以下内容:

  • 应用程序和Mongo之间的连接是否可靠?数据包丢弃率和延迟是多少?
  • 应用程序和Mongo之间是否有足够的网络带宽?
  • 应用程序/ Mongo服务器上是否有任何软件/硬件问题?
  • 服务器何时发生高负荷?