|
|
@@ -27,6 +27,7 @@ import javax.net.ssl.SSLException;
|
|
|
import javax.net.ssl.SSLHandshakeException;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InterruptedIOException;
|
|
|
+import java.net.SocketException;
|
|
|
|
|
|
/**
|
|
|
* http 同步连接池、http 异步连接池,与spring集成
|
|
|
@@ -125,22 +126,26 @@ public class HttpClientSpringFactory {
|
|
|
public boolean retryRequest(IOException exception,
|
|
|
int executionCount, HttpContext context) {
|
|
|
logger.info("http request occurs error:{}", exception.getMessage());
|
|
|
- if (executionCount >= 5) {// 如果已经重试了5次,就放弃
|
|
|
+ if (executionCount >= 3000) {// 如果已经重试了3000次,就放弃
|
|
|
return false;
|
|
|
}
|
|
|
- if (exception instanceof NoHttpResponseException) {// 如果服务器丢掉了连接,那么就重试
|
|
|
- return true;
|
|
|
- }
|
|
|
if (exception instanceof SSLHandshakeException) {// 不要重试SSL握手异常
|
|
|
return false;
|
|
|
}
|
|
|
- if (exception instanceof InterruptedIOException) {// 超时
|
|
|
- return false;
|
|
|
- }
|
|
|
if (exception instanceof SSLException) {// SSL握手异常
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ if (exception instanceof NoHttpResponseException) {// 如果服务器丢掉了连接,那么就重试
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (exception instanceof InterruptedIOException) {// 超时
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (exception instanceof SocketException) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
HttpClientContext clientContext = HttpClientContext
|
|
|
.adapt(context);
|
|
|
HttpRequest request = clientContext.getRequest();
|
|
|
@@ -148,7 +153,7 @@ public class HttpClientSpringFactory {
|
|
|
if (!(request instanceof HttpEntityEnclosingRequest)) {
|
|
|
return true;
|
|
|
}
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
};
|
|
|
|