I have been using using org.apache.http.client.HttpClient
to download some data from a HTTP server for past 2 years and its been working fine.
Recently we switched to HTTPS for some security reasons.This is also working fine with WiFi and High speed mobile data(3G).But most often with slow data connection(2G) My download interrupted with following stack trace.
javax.net.ssl.SSLException: Read error: ssl=0x56e63588: 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:690)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)
at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:120)
at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:131)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:140)
at java.io.FilterInputStream.read(FilterInputStream.java:114)
This is how my Code Looks like :
HttpPost httpPost = new HttpPost(url);
UrlEncodedFormEntity p_entity = new UrlEncodedFormEntity(
params, HTTP.UTF_8);
httpPost.setEntity(p_entity);
response = httpClient.execute(httpPost);
DataInputStream in = new DataInputStream(response.getEntity().getContent());
String st = "";
result = new Vector<String>();
while ((st = readLine(in)) != null) {
result.addElement(st);
}