HttpClient中的超时设置和请求重试
1,设置get方法请求超时为 5 秒
- GetMethod getMethod=new GetMethod(url);
- getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT,5000);
GetMethod getMethod=new GetMethod(url);
getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT,5000);
2,设置 Http 连接超时为5秒
- HttpClient httpClient=new HttpClient();
- httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
HttpClient httpClient=new HttpClient();
httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
设置连接超时和请求超时,这两个超时的意义不同,需要分别设置。
来源:http://xuganggogo.iteye.com/blog/366562
不用客气
向您请教超时后,再进行重试的代码的例子。非常感谢您!
捕获异常进行重试。
请教如何重试?