sky*_*ler 5 java android httpclient
我正在使用Apache HTTP commons DefaultHttpClient,在构建之后,我正在设置它的重试处理程序:
httpClient.setHttpRequestRetryHandler(new HttpRequestRetryHandler() {
@Override
public boolean retryRequest(final IOException ioe,
final int numRetry, final HttpContext context)
{
Log.d(TAG, "retry handler received exception of type: " + ioe.getClass().getName() + ", num retries: " + numRetry);
if (numRetry > 4) { // 3 retries
return false;
}
// Some exceptions we can retry without knowledge of which methods are being invoked
if (ioe instanceof NoHttpResponseException
|| ioe instanceof UnknownHostException
|| ioe instanceof SocketException) {
}
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
我发送请求的服务器经常超时,而在catch我的execute()调用中,我收到IO错误,"操作超时"但是我从未看到任何"重试处理程序收到类型的异常"日志我的控制台输出中的语句.我的所有请求都是POST请求,但它们是幂等的 - 它们可以安全地多次调用而没有不良的副作用.
我是否错误地设置了重试处理程序?是否仅在某些情况下调用重试处理程序?
| 归档时间: |
|
| 查看次数: |
2192 次 |
| 最近记录: |