Browse Source

fix bug

release_toaliyun_real
xiaohanzi 5 years ago
parent
commit
1cf5e0b57f
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      mallinkService/src/main/java/com/iformall/common/FmHttpClientBuilder.java

+ 7
- 1
mallinkService/src/main/java/com/iformall/common/FmHttpClientBuilder.java View File

@@ -20,6 +20,7 @@ import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
@@ -245,13 +246,18 @@ public class FmHttpClientBuilder implements ApacheHttpClientBuilder {

this.httpClientBuilder = HttpClients.custom().setConnectionManager(connectionManager)
.setConnectionManagerShared(true)
.setKeepAliveStrategy(DefaultConnectionKeepAliveStrategy.INSTANCE)
.setDefaultRequestConfig(
RequestConfig.custom()
.setSocketTimeout(this.soTimeout)
.setConnectTimeout(this.connectionTimeout)
.setConnectionRequestTimeout(this.connectionRequestTimeout)
.build())
.setRetryHandler(this.httpRequestRetryHandler);
.setRetryHandler(this.httpRequestRetryHandler)
.evictExpiredConnections()
//MaxIdleTime 必须小于服务端的关闭时间否则有可能出现NoHttpResponse
.evictIdleConnections(3,TimeUnit.SECONDS);//用来关闭闲置连接,它会启动一个守护线程进行清理工作。用户可以通过builder#evictIdleConnections开启该组件,并通过builder#setmaxIdleTime设置最大空闲时间。
;

if (StringUtils.isNotBlank(this.httpProxyHost) && StringUtils.isNotBlank(this.httpProxyUsername)) {
// 使用代理服务器 需要用户认证的代理服务器


Loading…
Cancel
Save