jersey
  1. jersey
  2. JERSEY-1175

When using apache-http-client connect timeouts are not honoured for proxy connects

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.11, 1.12
    • Fix Version/s: 1.17
    • Component/s: connectors
    • Labels:
      None
    • Environment:

      Squid proxy that ran out of file handles and could not response to CONNECT requests

      Description

      We ran into a scenario when a proxy would accept a connect request and not respond.

      It turns out that the commons-httpclient library will not use the timeout

      httpClientConfig.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, connectTimeoutInMillis);

      for the ConnectMethod used when doing the proxy connect

      I found that I needed to do this to encourage the http client to actually timeout on the proxy connect
      ApacheHttpClient client = ApacheHttpClient.create(httpClientConfig);
      client.getClientHandler().getHttpClient().getHttpConnectionManager().getParams().setSoTimeout(connectTimeoutInMillis);

      Although this is actually a read timeout on the connect request rather than a true connect timeout.

      To simulate a hanging proxy I used netcat like so... but anything that can open a socket and do nothing will work as well
      nc -l -p 5865

      Which would receive the following request and not respond...
      CONNECT xml.trn.secure-travel.net:443 HTTP/1.1
      User-Agent: Jakarta Commons-HttpClient/3.1
      Host: xml.trn.secure-travel.net
      Proxy-Connection: Keep-Alive

        Activity

        Hide
        Pavel Bucek added a comment -

        closing as won't fix.

        If I understood it correctly, you already found a working way how to set property you need, right? Additionally, PROPERTY_CONNECT_TIMEOUT is not declared as supported (see http://jersey.java.net/nonav/apidocs/latest/contribs/jersey-apache-client4/index.html), so this is more like enhancement request than bug report..

        Client API is going to be changed in JAX-RS 2.0 (it contains Client API now and it's quite different).

        feel free to comment or convince me that this should be addressed in future 1.x release.

        Show
        Pavel Bucek added a comment - closing as won't fix. If I understood it correctly, you already found a working way how to set property you need, right? Additionally, PROPERTY_CONNECT_TIMEOUT is not declared as supported (see http://jersey.java.net/nonav/apidocs/latest/contribs/jersey-apache-client4/index.html ), so this is more like enhancement request than bug report.. Client API is going to be changed in JAX-RS 2.0 (it contains Client API now and it's quite different). feel free to comment or convince me that this should be addressed in future 1.x release.

          People

          • Assignee:
            Pavel Bucek
            Reporter:
            stickycode
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: