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: