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 8867135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:57:23+00:00 2026-06-14T16:57:23+00:00

I am trying to implement HttpRequestRetryHandler in my Android app. I have read the

  • 0

I am trying to implement HttpRequestRetryHandler in my Android app. I have read the documentation for HttpRequestRetryHandler here.

DefaultHttpClient httpclient = new DefaultHttpClient();

HttpRequestRetryHandler myRetryHandler = new HttpRequestRetryHandler() {

    public boolean retryRequest(
            IOException exception, 
            int executionCount,
            HttpContext context) {
        if (executionCount >= 5) {
            // Do not retry if over max retry count
            return false;
        }
        if (exception instanceof InterruptedIOException) {
            // Timeout
            return false;
        }
        if (exception instanceof UnknownHostException) {
            // Unknown host
            return false;
        }
        if (exception instanceof ConnectException) {
            // Connection refused
            return false;
        }
        if (exception instanceof SSLException) {
            // SSL handshake exception
            return false;
        }
        HttpRequest request = (HttpRequest) context.getAttribute(
                ExecutionContext.HTTP_REQUEST);
        boolean idempotent = !(request instanceof HttpEntityEnclosingRequest); 
        if (idempotent) {
            // Retry if the request is considered idempotent 
            return true;
        }
        return false;
    }

};

httpclient.setHttpRequestRetryHandler(myRetryHandler);

The example in documentation states that certain exceptions should not be retried. For example InterruptedIOException should not be retried.

Question 1 Why InterruptedIOException should not be retried?

Question 2 How to know which exception to retry and which should not? For example – Should we retry ConnectionTimeoutException and SocketTimeoutException or not?

Also documentation says HttpClient assumes non-entity enclosing methods such as GET and HEAD to be idempotent and entity enclosing methods such as POST and PUT to be not.

Question 3 Does this mean we should not retry POST and PUT method and if not, then how should we retry HttpPost request?

  • 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-14T16:57:26+00:00Added an answer on June 14, 2026 at 4:57 pm

    I think its just an example of RetryHandler implementation.

    Question 1 Why InterruptedIOException should not be retried?

    In the example, I believe it’s assumed that cause of timeout is resource unavailability at URL and hence retry will not do anything better. That’s the reason, it’s set to false. If in your case, you think it may be just because of slow connection or some intermittent issue, feel free to set it true for retry.

    Question 2 How to know which exception to retry and which should not? For example – Should we retry ConnectionTimeoutException and SocketTimeoutException or not?

    Any exception, which you believe that it’s because of transient issue, you may retry. Any exception whose cause is more of permanent in the nature e.g. Resource Not Found or some business exception shouldn’t be retried as they will always fail.

    Question 3 Does this mean we should not retry POST and PUT method and if not, then how should we retry HttpPost request?

    Retry is permitted only for the scenarios where you can re-initiate the process without any external dependency.

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

Sidebar

Related Questions

Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
Im trying to implement GA in my android app. When i call 'GoogleAnalyticsTracker.getInstance()' i
Trying to implement page turning animation exactly as the flipboard ipad app. I have
Trying to implement a search similar to here .This searches properties based on city,locality,property
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
I am trying implement a photo gallery similar to facebook in Android. I was
Trying to implement NSCopying for the first time, and I have a question about
I have this weird kind of error. I am trying implement basic Euclidean algorithm
Trying to implement what I thought was a simple concept. I have a user
Trying to implement the example from here. Facebook Share passes along the URL of

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.