title: How do I set a connection timeout in Apache http client?
body: <p>I want to run thread safe, asynchronous HTTP requests using <a href="http://hc.apache.org/httpcomponents-asyncclient-dev/index.html" rel="noreferrer">HTTPClient</a>. I noticed that it does not respect my <code>CONNECTION_TIMEOUT</code> argument.</p>
  
  <p>The code is ColdFusion / Java hybrid.</p>
  
  <pre><code>client = loader.create("org.apache.http.impl.nio.client.DefaultHttpAsyncClient").init();
  CoreConnectionPNames = loader.create("org.apache.http.params.CoreConnectionPNames");
  
  client.getParams()
        .setIntParameter(JavaCast("string", CoreConnectionPNames.SO_TIMEOUT), 10)
        .setIntParameter(JavaCast("string", CoreConnectionPNames.CONNECTION_TIMEOUT), 10);
  
  client.start();
  
  request = loader.create("org.apache.http.client.methods.HttpGet").init("http://www.google.com");
  future = client.execute(request, javacast("null", ""));
  
  try {
     response = future.get();
  }
  catch(e any) {}
  
  client.getConnectionManager().shutdown();
  </code></pre>
  
  <p> 
  Regardless of what I supply for CONNECTION_TIMEOUT, the requests always return 200 OK. Check the output below.</p>
  
  <ol>
  <li>How do I set an effective connection timeout?</li>
  <li>Does CONNECTION_TIMEOUT do anything?</li>
  </ol>
  
  <p>Output</p>
  
  <pre><code>200 OK http://www.google.com/
  
  200 OK http://www.google.com/
  
  [snip]
  
  5 requests using Async Client in: 2308 ms
  </code></pre>