Java.net.SocketTimeoutException:Read timed out

Source: Internet
Author: User


http://xye-462438944-163-com.iteye.com/blog/1205894

When the method Executemethod in the Org.apache.commons.httpclient.HttpClient class is invoked, such as:

Java code httpclient client = new HttpClient ();       HttpGet = new GetMethod (URL); Client.getparams (). Setintparameter ("Http.socket.timeout", 3000);

HttpClient client = new HttpClient ();

HttpGet = new GetMethod (URL);

Client.getparams (). Setintparameter ("Http.socket.timeout", 3000);
Java code Client.executemethod (httpget);
Client.executemethod (HttpGet);

The system may have java.net.SocketTimeoutException:Read timed out exceptions, which can be accessed when you enter the URL link directly in the browser, possibly because HttpClient has a time-out limit when it gets the link. This is just to remove the timeout limit. The code is Client.getparams (). Setintparameter ("Http.socket.timeout", 3000); Comment out or extend its timeout limit


http://mywork.iteye.com/blog/430754


The following error
Java.net.SocketTimeoutException:Read timed out

was found after the two-day project was passed through URLConnection in a test environment because:
The client does not send the data to the server within a limited time, and the server finds that the connection has failed to ensure service performance, so the above exception occurs.

The solution is:
Increase the timeout for the client.
such as Java code   system.setproperty ("Sun.net.client.defaultConnectTimeout",  string                          .valueof (10000));//  (unit: MS)                 system.setproperty ("Sun.net.client.defaultReadTimeout",  string                         .valueof (10000));  //  (unit: milliseconds)   

System.setproperty ("Sun.net.client.defaultConnectTimeout", String
					. valueof (10000));//(in milliseconds)
			System.setproperty ("Sun.net.client.defaultReadTimeout", String
					. valueof (10000));//(unit: milliseconds)
Share to:

Related Article

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.