title: Android - Loopj AsyncHttpClient: error on second http request with 3g data connection
body: <p>I've done long search before doing this post and I've done many test but without success.</p>
  
  <p><strong>My Problem (in short):</strong> with 3g data connection, every time I do a <strong>get request</strong>, the first time the connection complete with success. </p>
  
  <p>Now, if the device go in standby for few minuts, when I repeat the same <strong>get request</strong> it fails istantly with the error that I've reported below. Some comments:</p>
  
  <ol>
  <li>I'm having this issue only with a <strong>Rooted Nexus 5 (Android 4.4.2)</strong></li>
  <li>If the device don't go in standby, I can't reproduce the problem</li>
  <li>If I try a third time, the connection complete with success.</li>
  <li>In WiFi mode I can't reproduce the problem.</li>
  <li>Tested also with Galaxy S3 (android 4.3) and Galaxy S1 and can't reproduce the problem.</li>
  <li>I'm using last version of <strong>Loopj AsyncHttpClient libray (1.4.4)</strong> found here: <a href="http://loopj.com/android-async-http/doc/com/loopj/android/http/AsyncHttpClient.html" rel="nofollow">http://loopj.com/android-async-http/doc/com/loopj/android/http/AsyncHttpClient.html</a></li>
  </ol>
  
  <p><strong>ERROR DETAIL</strong></p>
  
  <pre><code>javax.net.ssl.SSLException: Read error: ssl=0x75cab460: I/O error during system call,   
  Connection reset by peer
  at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
  at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:689)
  at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)
  at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:191)
  at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:82)
  at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174)
  at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180)
  at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
  at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
  at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
  at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
  at com.loopj.android.http.AsyncHttpRequest.makeRequest(AsyncHttpRequest.java:74)
  at com.loopj.android.http.AsyncHttpRequest.makeRequestWithRetries(AsyncHttpRequest.java:91)
  at com.loopj.android.http.AsyncHttpRequest.run(AsyncHttpRequest.java:54)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  at java.lang.Thread.run(Thread.java:841)
  
  Response body is null, calling onFailure(Throwable, JSONObject)
  </code></pre>
  
  <p><strong>Let's see some code.</strong></p>
  
  <p>I have a singleton class where I manage all connections:</p>
  
  <pre><code>...
  //Static istance of my httpClient
  private static AsyncHttpClient client = new AsyncHttpClient();
  //This is the only parameter that I'm setting for the client
  client.setTimeout(30000);
  ...
  
  //When i need to a get request I just use the following code.
  client.get(mContext, url, params, responseHandler);
  
  //For testing purpose, before doing any get request, I've done a clear of all requests,
  //but this is not helping with my problem.
  client.cancelRequests(mContext, true);
  </code></pre>
  
  <p>I'm lost now: I don't know if I am missing some configuration parameters on the client, or if the client is trying to reuse a wrong connection, etc...</p>
  
  <p>I'm a new user of the library, so I can really be doing something wrong.</p>
  
  <p>I hope someone can help me.</p>
  
  <p>Thanks in advance.</p>