From 78a1215d133024b9a51afa29c2973e0bc046fb9b Mon Sep 17 00:00:00 2001 From: Ryan Amari Date: Sun, 3 Nov 2024 20:52:48 -0500 Subject: [PATCH] Set timout to 15 seconds --- .../edu/harvard/dbmi/avillach/util/HttpClientUtil.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pic-sure-util/src/main/java/edu/harvard/dbmi/avillach/util/HttpClientUtil.java b/pic-sure-util/src/main/java/edu/harvard/dbmi/avillach/util/HttpClientUtil.java index c64dce23..cc381759 100644 --- a/pic-sure-util/src/main/java/edu/harvard/dbmi/avillach/util/HttpClientUtil.java +++ b/pic-sure-util/src/main/java/edu/harvard/dbmi/avillach/util/HttpClientUtil.java @@ -295,6 +295,12 @@ public InputStream simpleGetWithConfig( public static HttpClient getConfiguredHttpClient(HttpClientConnectionManager connectionManager) { try { + int timeout = 15; + RequestConfig config = RequestConfig.custom() + .setConnectTimeout(timeout * 1000) + .setConnectionRequestTimeout(timeout * 1000) + .setSocketTimeout(timeout * 1000).build(); + SSLConnectionSocketFactory.getSocketFactory(); SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(null, null, null); @@ -317,6 +323,7 @@ public static HttpClient getConfiguredHttpClient(HttpClientConnectionManager con limited.toArray(new String[limited.size()]), SSLConnectionSocketFactory.getDefaultHostnameVerifier())) .setConnectionManager(connectionManager) + .setDefaultRequestConfig(config) .build(); } catch( NoSuchAlgorithmException | KeyManagementException e) { logger.warn("Unable to establish SSL context. using default client", e);