Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

SocketTimeoutException: Read timed out

Thread view: 
ivan.andrisek@gmail.com - 10 Aug 2006 15:55 GMT
Hi everybody,

I have a strange thing happening (at least to me) in my java program
and would appreciate help on the issue:

I am running on JRE 1.4.2_10 and using HttpUrlConnection class to
exchange some XML files with another machine and sometimes I get the
"SocketTimeoutException: Read timed out" exception.

What confuses me is the fact that in Java1.4.2, HttpUrlConnection class
does not support defining SO_TIMEOUT (as in Java1.5) which means that
my SO_TIMEOUT by default is 0 ==> indefinite.

Why do I get those Timeout Exceptions that? Is is possible that the
other side (that I am sending the XML file to) is denying connection
which causes this exception on some hidded socket classes inside
HttpUrlConnection?

Thanks in advance!
Ivan
js - 11 Aug 2006 01:50 GMT
> Hi everybody,
>
[quoted text clipped - 16 lines]
> Thanks in advance!
> Ivan

IIRC, it is OS dependent. In Linux, at least starting with kernel 2.6 ( not
sure with 2.4 ), you can set TCP keep-alive timeouts and interval
in /etc/sysctl.conf:

net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_intvl = 30
EJP - 11 Aug 2006 03:09 GMT
>>I am running on JRE 1.4.2_10 and using HttpUrlConnection class to
>>exchange some XML files with another machine and sometimes I get the
[quoted text clipped - 8 lines]
>>which causes this exception on some hidded socket classes inside
>>HttpUrlConnection?

No. The other end is certainly *not responding* with data, and you need
to investigate that. I'm not aware that any implementation of
HttpURLConnection sets a read timeout other than the user-defined one
@since 1.5.

>>Thanks in advance!
>>Ivan
>
> IIRC, it is OS dependent.

Nope. In every implementation of sockets the default read timeout is
supposed to be infinite.

> In Linux, at least starting with kernel 2.6 ( not
> sure with 2.4 ), you can set TCP keep-alive timeouts and interval
> in /etc/sysctl.conf:

Keepalive has nothing to do with read timeouts.
ivan.andrisek@gmail.com - 11 Aug 2006 14:03 GMT
Hi!

After further investigation, and talking with "the other end" i found
out that the other side has
timeout set to a very low value (1 second) which, in case of slower TCP
connection, caused all the exceptions.

thanks a lot for the tip!

BR
Ivan

> No. The other end is certainly *not responding* with data, and you need
> to investigate that. I'm not aware that any implementation of
> HttpURLConnection sets a read timeout other than the user-defined one
> @since 1.5.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.