Socket timeout when making HTTPGet requests using DefaultHTTPClient
<p>What are the pros and cons behind reusing <code>DefaultHTTPClient</code> when sending HTTP requests from an Android app to an external server? I tried using reusing a <code>DefaultHTTPClient</code> when making periodic <code>HTTPGet</code> requests, but I get random socket timeouts (specially when using 3G).</p>

<p>My code looks like follows:</p>

<pre><code>public class MyHTTPSender {
  private DefaultHTTPClient mClient;

  public MyHTTPSender() {
    mClient = new DefaultHTTPClient();
  }

  public void send(String httpAddress) {
HttpGet get = new HttpGet(this.surrogateURL);
    HttpResponse response = null;
try {
      response = httpClient.execute(get);
      // ... consume entity if OK          
    } catch (Exception e) {
    } finally {
        if (response != null) {
           // do some sanity checks to ensure Entity is there!
           response.getEntity().consumeContent();
        }
    }
  }
}
</code></pre>

<p>I can't see anything wrong with what I am doing. I have a separate handler that make HTTPPost requests, and that works perfectly well (uses a different DefaultHTTPClient object).</p>

<p>Any suggestions?</p>
