diff --git a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/HttpUtil.java b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/HttpUtil.java index baf3391ca..6172c6ac3 100644 --- a/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/HttpUtil.java +++ b/flink-doris-connector/src/main/java/org/apache/doris/flink/sink/HttpUtil.java @@ -17,15 +17,25 @@ package org.apache.doris.flink.sink; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.NoConnectionReuseStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultRedirectStrategy; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; +import java.util.concurrent.TimeUnit; + /** * util to build http client. */ public class HttpUtil { + private RequestConfig requestConfigStream = + RequestConfig.custom() + .setConnectTimeout(60 * 1000) + .setConnectionRequestTimeout(60 * 1000) + .build(); + private final HttpClientBuilder httpClientBuilder = HttpClients .custom() .setRedirectStrategy(new DefaultRedirectStrategy() { @@ -33,7 +43,11 @@ public class HttpUtil { protected boolean isRedirectable(String method) { return true; } - }); + }) + .setConnectionReuseStrategy(NoConnectionReuseStrategy.INSTANCE) + .evictExpiredConnections() + .evictIdleConnections(60, TimeUnit.SECONDS) + .setDefaultRequestConfig(requestConfigStream); public CloseableHttpClient getHttpClient() { return httpClientBuilder.build();