Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8181881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:40:09+00:00 2026-06-07T00:40:09+00:00

The app I am working on is supporting android 2.3 upwards. As the download

  • 0

The app I am working on is supporting android 2.3 upwards. As the download manager does not support https in 2.3(I can’t comprehend why), I am implementing my own version.

The problem I have is if android changes network (wifi to 3g etc) when downloading content I am getting the following error.

06-14 17:26:48.770: W/System.err(15648): javax.net.ssl.SSLException: Read error: ssl=0x270420: I/O error during system call, Connection timed out
06-14 17:26:48.770: W/System.err(15648):    at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_read(Native Method)
06-14 17:26:48.770: W/System.err(15648):    at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:788)
06-14 17:26:48.770: W/System.err(15648):    at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)
06-14 17:26:48.770: W/System.err(15648):    at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:134)
06-14 17:26:48.770: W/System.err(15648):    at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:174)
06-14 17:26:48.770: W/System.err(15648):    at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:188)
06-14 17:26:48.770: W/System.err(15648):    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:178)
06-14 17:26:48.770: W/System.err(15648):    at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:140)
06-14 17:26:48.770: W/System.err(15648):    at java.io.BufferedInputStream.read(BufferedInputStream.java:324)
06-14 17:26:48.770: W/System.err(15648):    at java.io.FilterInputStream.read(FilterInputStream.java:133)
06-14 17:26:48.770: W/System.err(15648):    at net.doo.download.ManualDocDownloader$AsyncDocDownloader.doInBackground(ManualDocDownloader.java:126)
06-14 17:26:48.770: W/System.err(15648):    at net.doo.download.ManualDocDownloader$AsyncDocDownloader.doInBackground(ManualDocDownloader.java:86)
06-14 17:26:48.770: W/System.err(15648):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-14 17:26:48.770: W/System.err(15648):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
06-14 17:26:48.780: W/System.err(15648):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
06-14 17:26:48.780: W/System.err(15648):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
06-14 17:26:48.840: W/System.err(15648):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
06-14 17:26:48.845: W/System.err(15648):    at java.lang.Thread.run(Thread.java:1019)

The code that is having the problem looks like this…

public class AsyncDocDownloader extends AsyncTask<String, Integer, Boolean> {

        private int id;
        private Notification notification;

        public AsyncDocDownloader(int id, Notification notification) {
            this.id = id;
            this.notification = notification;
        }

        @Override
        protected void onProgressUpdate(Integer... values) {

            notification.contentView.setProgressBar(R.id.status_progress, 100, values[0], false);

            notificationManager.notify(id, notification);
        }

        @Override
        protected Boolean doInBackground(String... values) {
            try {
                HttpGet get = new HttpGet(values[0]);
                HttpResponse resp = httpClientProvider.get().execute(get, context);
                    File dooDirectory = directoryProvider.get();
                    File fileName = new File(dooDirectory, values[1]);
                    InputStream input = new BufferedInputStream(resp.getEntity().getContent());
                    OutputStream output = new FileOutputStream(fileName);

                    int fileLength = Integer.valueOf(resp.getHeaders("Content-Length")[0].getValue());
                    int step = fileLength/20;
                    int counter = 0;
                    int progress = 0;


                    byte data[] = new byte[1024];
                    long total = 0;
                    int count;

                    while ((count = input.read(data)) != -1) {
                        total += count;
                        if(total > counter){
                            progress = progress + 5;
                            publishProgress(progress);
                            counter = step + counter;
                        }
                        output.write(data, 0, count);
                    }

                    output.close();
                    input.close();
                Log.d("DownloadDoc", "Completed download");
                return true;
            } catch (IOException e) {
                Log.d("DownloadDoc", "IOException");
                e.printStackTrace();
                return false;
            }
        }

        @Override
        protected void onPostExecute(Boolean success) {
            Log.d("DownloadDoc", "onPostExecute Called");
            if (success) {
                Intent i = new Intent(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
                application.sendBroadcast(i);
            } else {
                notification.flags = notification.flags | Notification.DEFAULT_ALL;
                notification.contentView.setTextViewText(R.id.status_text, "failed");
                notificationManager.notify(id, notification);
            }

        }
    }

The httpClient that is passed via the provider is configured like so (the provider is because I am using roboguice)

HttpParams params = new BasicHttpParams();

HttpRequestRetryHandler retryhandler = new DefaultHttpRequestRetryHandler(6, true);
// The params are read in the ctor of the pool constructed by
// ThreadSafeClientConnManager, and need to be set before constructing it.
ConnManagerParams.setMaxTotalConnections(params, 200);
ConnPerRoute cpr = new ConnPerRoute() {
    @Override
    public int getMaxForRoute(HttpRoute httpRoute) {
        return 50;
    }
};
ConnManagerParams.setMaxConnectionsPerRoute(params, cpr);

SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();


SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(
        new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https", SSLCertificateSocketFactory.getHttpSocketFactory(50000,
        new SSLSessionCache(context)), 443));


ClientConnectionManager conManager = new ThreadSafeClientConnManager(params, schemeRegistry);
DefaultHttpClient httpClient = new DefaultHttpClient(conManager, new BasicHttpParams());
httpClient.setHttpRequestRetryHandler(retryhandler);

Thanks for any advice

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:40:11+00:00Added an answer on June 7, 2026 at 12:40 am
    06-14 17:26:48.770: W/System.err(15648):    at net.doo.download.ManualDocDownloader$AsyncDocDownloader.doInBackground(ManualDocDownloader.java:126)
    06-14 17:26:48.770: W/System.err(15648):    at net.doo.download.ManualDocDownloader$AsyncDocDownloader.doInBackground(ManualDocDownloader.java:86)
    

    This suggest that your code is throwing an exception, which your try{}catch() is then propagating upwards.

    You should try catching SSLException as well as IOException so you can gracefully recover and restart your AsyncTask

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app was working and I did not change a single thing in the
I have made an android app which working fine. I implemented the Login functionality
I have my app working with Sunspot Solr locally, supporting unicode with no issues.
We found that your app does not comply with the Apple iOS Human Interface
I'm trying out CakePHP now and I can't get my app working because CakePHP
I am working on the Android app. I searched a lot posts before create
The iPad app that I'm currently working on reads .epub files from the Supporting
My google maps embedded android app working correctly on emulator and real device but
I have my php app working fine, performing some other Graph API functions. However,
I had a working Active Admin app working on my local server, but after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.