SocketTimeoutException: Read timed out

Discussion in 'Java' started by ivan.andrisek@gmail.com, Aug 10, 2006.

  1. Guest

    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
     
    , Aug 10, 2006
    #1
    1. Advertising

  2. js Guest

    wrote:

    > 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


    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
     
    js, Aug 11, 2006
    #2
    1. Advertising

  3. EJP Guest

    js wrote:

    > wrote:
    >
    >>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?


    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.
     
    EJP, Aug 11, 2006
    #3
  4. Guest

    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.
     
    , Aug 11, 2006
    #4
  5. anupam

    Joined:
    Nov 1, 2012
    Messages:
    1
    read time out excetion in httppost

    Hi,

    We have adaptor jar (java ) which send some xml data to another web component deployed on other linux box using httppost method but after couple of hours I am getting read time out excetion in the adaptor and it is not able to send data.
    Once I restart the web component then again it work for some time.
    can any one help me to figure out the probel and how to fix this?
     
    anupam, Nov 1, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    0
    Views:
    5,443
    Steve
    Jul 1, 2003
  2. sven abels

    Strange SocketTimeoutException

    sven abels, Dec 1, 2003, in forum: Java
    Replies:
    0
    Views:
    481
    sven abels
    Dec 1, 2003
  3. Andre Raue
    Replies:
    2
    Views:
    7,928
    Nigel Wade
    Apr 14, 2004
  4. Replies:
    5
    Views:
    6,375
    jan V
    Sep 3, 2005
  5. laredotornado
    Replies:
    2
    Views:
    4,650
Loading...

Share This Page