-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.9.3, 2.10.1
-
Component/s: Connection Management
-
Environment:Ubuntu 12.10
I have a simple web application running in Apache Tomcat that is attempting to read a document from mongo on some user action. While this generally works, it occasionally throws a Read timeout Exception (full stack trace at the end).
I've observed that this usually happens when there is no activity on the server for some time - but I unable to ascertain the duration of inactivity. I also know that this is not a connectivity issue - I wrote a small application that does a read every second. This app continues to run during the time when my web app complains about timeout. Another interesting observation is that this problem does not occur for clients on the same machine as mongo server.
I've done some reading & figured that reducing keep alive time interval might help but I'm not sure on that. Is there a recommended setting for keep alive time interval?
My configuration parameters are as following
mongoOptions.connectTimeout=5000
mongoOptions.socketTimeout=60000
mongoOptions.socketKeepAlive=true
mongoOptions.maxWaitTime=15000
mongoOptions.autoConnectRetry=true
Additional Settings
I'm using Java Driver 2.10.1 on a linux box (Ubuntu server 12.10) and connecting to mongo server 2.0.6 running on windows server 2008. I'm using JDK 7
Stack Trace
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
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:124)
at com.mongodb.DBPort.call(DBPort.java:74)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:286)
... 42 more