Skip to content

Commit e88313c

Browse files
authored
DEV-29238 Close idle connections after 4 seconds (#91)
Allow connections to be idle for up to 4 seconds before not reusing. This strategy is needed because we are seeing connections being closed by the server after 4 seconds, then when we attempt to use, the call fails.
1 parent 17f887b commit e88313c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/HttpClientFactoryImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public CloseableHttpClient create() throws B2Exception {
7676
.setUserAgent(APACHE_HTTP_CLIENT_USER_AGENT)
7777
.setConnectionManager(connectionManager)
7878
.setDefaultRequestConfig(requestConfig)
79+
// Allow connections to be idle for up to 4 seconds before not reusing. This strategy is needed
80+
// because we are seeing connections being closed by the server after 4 seconds, then when we attempt
81+
// to use, the call fails.
82+
.setKeepAliveStrategy((httpResponse, httpContext) -> 4000)
7983
.build();
8084
}
8185

0 commit comments

Comments
 (0)