[JAVA-721] Read Time out intermittently while reading Created: 28/Dec/12  Updated: 05/Jan/13  Resolved: 05/Jan/13

Status: Closed
Project: Java Driver
Component/s: Connection Management
Affects Version/s: 2.9.3, 2.10.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Guneet Sahai Assignee: Unassigned
Resolution: Done Votes: 0
Labels: connections, timeout
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 12.10



 Description   

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



 Comments   
Comment by Guneet Sahai [ 05/Jan/13 ]

The problem seems to have been solved for me. Here's the resolution:

Additional Information - On one of the environments, I have monogo server running on version 2.2.x. This problem does not occur there with the same driver version.

On my testing environment where the mongo server version is 2.0.3 - I tried reducing the keepalive time to 5 mins (as advised at http://docs.mongodb.org/manual/faq/diagnostics/ from 2 hours) on the client machine (running on linux) & that helped.

I haven't seen the problem re-occur for last couple of days. Can close the issue (I couldn't find a way to do this myself).

Generated at Thu Feb 08 08:52:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.