|
14 | 14 | import org.apache.http.client.methods.CloseableHttpResponse; |
15 | 15 | import org.apache.http.client.methods.HttpPost; |
16 | 16 | import org.apache.http.client.protocol.HttpClientContext; |
| 17 | +import org.apache.http.config.SocketConfig; |
17 | 18 | import org.apache.http.conn.routing.HttpRoute; |
18 | 19 | import org.apache.http.entity.StringEntity; |
19 | 20 | import org.apache.http.impl.client.*; |
@@ -80,6 +81,7 @@ private void initializeConnectionManager(MerchantConfig merchantConfig) throws C |
80 | 81 | String hostname = uri.getHost(); |
81 | 82 | connectionManager = new PoolingHttpClientConnectionManager(); |
82 | 83 | connectionManager.setDefaultMaxPerRoute(merchantConfig.getDefaultMaxConnectionsPerRoute()); |
| 84 | + connectionManager.setDefaultSocketConfig(SocketConfig.custom().setSoKeepAlive(true).setSoTimeout(mc.getSocketTimeoutMs()).build()); |
83 | 85 | connectionManager.setMaxTotal(merchantConfig.getMaxConnections()); |
84 | 86 | connectionManager.setValidateAfterInactivity(mc.getValidateAfterInactivityMs()); |
85 | 87 | final HttpHost httpHost = new HttpHost(hostname); |
@@ -350,7 +352,7 @@ public boolean retryRequest(IOException exception, int executionCount, HttpConte |
350 | 352 | if (StringUtils.isBlank(errMessage)) { |
351 | 353 | errMessage = exception.getLocalizedMessage(); |
352 | 354 | } |
353 | | - if (StringUtils.isNotBlank(errMessage) && "Connection reset".equalsIgnoreCase(errMessage)) { |
| 355 | + if (StringUtils.isNotBlank(errMessage) && ( errMessage.equalsIgnoreCase("Connection reset") || errMessage.contains("Connection reset"))) { |
354 | 356 | retryAfter(retryWaitInterval, executionCount, logger); |
355 | 357 | return true; |
356 | 358 | } |
|
0 commit comments