Why do I end up with java.lang.IllegalArgumentExce

2020-06-30 09:06发布

I'm seeing a strange issue using the casbah / java driver.

I keep running into the following exception when the driver tries to create a response from mongo:


  Oct 16, 2012 10:45:07 AM com.mongodb.DBTCPConnector$MyPort error
  SEVERE: MyPort.error called
  java.lang.IllegalArgumentException: response too long: 1634610484
    at com.mongodb.Response.(Response.java:40)
    at com.mongodb.DBPort.go(DBPort.java:110)
    at com.mongodb.DBPort.go(DBPort.java:75)
    at com.mongodb.DBPort.call(DBPort.java:65)
    at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:201)
    at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
    at com.mongodb.DBCursor._check(DBCursor.java:354)
    at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
    at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
    at com.mongodb.casbah.MongoCursorBase$class.hasNext(MongoCursor.scala:73)
    at com.mongodb.casbah.MongoCursor.hasNext(MongoCursor.scala:497)
    at scala.collection.Iterator$class.foreach(Iterator.scala:660)
    at com.mongodb.casbah.MongoCursor.foreach(MongoCursor.scala:497)
        ...

This seems to be happening at random, even in cases where mongo shouldn't be returning any results from the query. The size reported is inconsistent and normally way larger than it should or could be.

I'm guessing this is probably some form of corruption with the response. I've had a difficult time making heads or tails of this problem using Wireshark, but I consistently find that the request/response chain leading up to the query whose response throws this error has "TCP Window Full" response coming from MongoDB:

enter image description here

The versions I'm using:


 Casbah: 2.1.5.0
 Mongo Java Driver: 2.5.3
 MongoDB: 2.2

I'd greatly appreciate it if anyone could give any advice on what I may potentially be doing wrong or any pointers on how to further debug this issue

UPDATE: After looking at the release notes for Casbah 2.1.5.0, it appears that the version of the java driver being used is 2.5.3, not 2.7.3

2条回答
疯言疯语
2楼-- · 2020-06-30 09:13

The version of the Java driver you're using is not compatible with MongoDB 2.2. You should be using at least 2.9.3, if not 2.10 or higher. There's no guarantee a driver upgrade will fix your problem, but it should be a first step.

https://support.mongolab.com/entries/22631012-which-drivers-support-mongodb-2-2

查看更多
劳资没心,怎么记你
3楼-- · 2020-06-30 09:21

How big is your JSON object? See if that big object is supported by the version of mongodb.

查看更多
登录 后发表回答