Skip to content

Commit

Permalink
Set timout to 15 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Nov 4, 2024
1 parent 8483750 commit 78a1215
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 78a1215

Please sign in to comment.