title: Java HTTP Client Request with defined timeout
body: <p>I would like to make BIT (Built in tests) to a number of server in my cloud. I need the request to fail on large timeout.</p>
  
  <p>How should I do this with java?</p>
  
  <p>Trying something like the below does not seem to work.</p>
  
  <pre><code>public class TestNodeAliveness {
   public static NodeStatus nodeBIT(String elasticIP) throws ClientProtocolException, IOException {
    HttpClient client = new DefaultHttpClient();
    client.getParams().setIntParameter("http.connection.timeout", 1);
  
    HttpUriRequest request = new HttpGet("http://192.168.20.43");
    HttpResponse response = client.execute(request);
  
    System.out.println(response.toString());
    return null;
   }
  
  
   public static void main(String[] args) throws ClientProtocolException, IOException {
    nodeBIT("");
   }
  }
  </code></pre>
  
  <p>-- EDIT: Clarify what library is being used --</p>
  
  <p>I'm using httpclient from apache, here is the relevant pom.xml section</p>
  
  <pre><code> &lt;dependency&gt;
     &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
     &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
     &lt;version&gt;4.0.1&lt;/version&gt;
     &lt;type&gt;jar&lt;/type&gt;
   &lt;/dependency&gt;
  </code></pre>