Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-478

HttpConnectionParams.setConnectionTimeout(int) has no effect if host unreachable

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0 RC3
    • Fix Version/s: 3.0 Final
    • Component/s: HttpClient (classic)
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC
    • Bugzilla Id:
      35642

      Description

      I have just modified MultiThreadedExample.java by adding
      httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); in
      order to set a connection timeout on the client side. Then I have added a LAN
      url to urisToGet array. The ip of this url ("http://192.168.254.1/") is not
      assigned to any computer.

      After running the client, I get the expected message ( error:
      org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept
      the connection within timeout of 5000 ms) but only after 20 seconds.

      I use java version "1.5.0_04". This is not a JVM bug since normal connection
      procedure times out after 5 seconds as expected:
      SocketAddress addr = new InetSocketAddress("192.168.254.1", 80);
      try

      { SocketChannel channel = SocketChannel.open(); channel.socket().connect(addr, 5000); System.out.println("connected"); }

      catch (Exception e)

      { e.printStackTrace(); }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              seven Horia Muntean
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: