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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:56:26+00:00 2026-05-26T23:56:26+00:00

I am currently working on a project which is using Apache HttpClient 4.1.2 and

  • 0

I am currently working on a project which is using Apache HttpClient 4.1.2 and it retrieves some data from a website.

What the application does: it goes to a webpage and then goes to the next (found) pages until it reaches the end (e.g.: go to page 1 -> finds 20 more pages -> go to every next 20 pages). The problem is that it gets stuck on retrieving some random pages and it doesn’t continue the crawl.

Here is some code:

DefaultHttpClient mainHttp;
HttpPost post;
HttpResponse response;
HttpEntity entity;
String s;
int curPage = 1;
int index = 0;
boolean ok = true;

...

while (ok) { 
  response = mainHttp.execute(post);
  entity = response.getEntity();
  if (entity != null) {
    System.out.println("Enter " + curPage);
    s = EntityUtils.toString(entity);
    System.out.println("Exit " + curPage);
    index = s.indexOf("[" + curPage + "]");
    if (index > 0) {
      parseContent();
    } else {
      ok = false;
    }                
  }
}

On the debug window is shows something like this:

Enter 1
Exit 1
.
.
.
Enter n

I am also using a http request analyzer and I saw that on the page that stucks, the data is not retrieved completely (it doesn’t reach the </html> or the end of the page).

What can I do to skip or retry downloading the data in such cases? Can anyone help me?

Thank you!

LE:

The actual settings were:

mainHttp.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(1, true));
mainHttp.getParams().setParameter("http.connection-manager.timeout", 15000);
mainHttp.getParams().setParameter("http.socket.timeout", 15000);
mainHttp.getParams().setParameter("http.connection.timeout", 15000);

where 15000 is the timeout in miliseconds.

Thank you for your help.

  • 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-05-26T23:56:27+00:00Added an answer on May 26, 2026 at 11:56 pm
    DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler(1, true);
    mainHttp.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);   
    

    Source: http://hc.apache.org/httpclient-3.x/tutorial.html (Method recovery)

    But this is only if there were any exceptions that occurred, try checking for IOExceptions every time you make a request

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

Sidebar

Related Questions

I am currently working on a project which requires migration of content from different
I'm currently working on a Haskell project which automatically tests some functions based on
I'm currently working on a project which uses XSL-Transformations to generate HTML from XML.
I'm currently working on a project which is using EF Code First with POCOs.
I'm currently working on a project which is using EF Code First with POCOs.
I'm currently working on a simple web project, for which I am using the
I'm currently working on a project which will support multiple file writing specifications (imagine
I'm currently working on my project which consists of front and back-end written in
Our team is currently working on a large project which makes heavy use of
Currently we are working on a project in which we need to come up

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.