title: Java HTTP Client request set timeout
body: <p>I want to set the timeout of a request. This is the code, I've got so far.</p>
  
  <pre><code>final HttpClient httpclient = HttpClients.createDefault();
  final HttpPost httppost = new HttpPost(address);
  httppost.setHeader("Accept", "text/xml");
  httppost.setHeader("Content-type", "application/xml; charset=UTF-8");
  httppost.setEntity(new StringEntity(body));
  final HttpResponse response = httpclient.execute(httppost);
  final HttpEntity entity = response.getEntity();
  </code></pre>
  
  <p>I've tried (does not work, keeps loading and ignores timeout)</p>
  
  <pre><code>// set the connection timeout value to 30 seconds (30000 milliseconds)
  final HttpParams httpParams = new BasicHttpParams();
  HttpConnectionParams.setConnectionTimeout(httpParams, 30000);
  client = new DefaultHttpClient(httpParams);
  </code></pre>
  
  <p>and (this one throws <code>java.lang.UnsupportedOperationException</code>)</p>
  
  <pre><code>httpclient = HttpClients.createDefault();
  httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000);
  httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 6000);
  </code></pre>
  
  <p>Is there any other way for setting the timout? I don't really need the response so something like an asynchronous request could do the work too.</p>