Android or Java solution for sending HTTP automatic resend requests

Source: Internet
Author: User

Today, a wonderful problem is described as follows:

The client initiates one time to the server (it can be seen from the log that only one log is printed), but there are repeated requests for data on the backend at the back end. This problem is not easy to appear, and in Chinese search is not the corresponding results;

A solution to the problem is found today in a foreign site:

The reasons are as follows: Due to the time-out of the link and fetch data, after the client sends the data, it detects that it may not be sent successfully to the backend, this time the HTTP underlying will automatically resend the request (note that the HTTP underlying, so the application will not know that many requests were sent). If the application side automatically re-sends multiple requests, the backend also responds to multiple requests, but the previous paragraph only replies 1 requests. So in order to solve this problem, as long as the defaulthttpclient set the following code can be resolved:

defaultHttpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));

 

Android or Java solution for sending HTTP automatic resend requests

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.