1

We've defined a HTTPClient bean in Spring Boot the following way:

@Configuration
public class HttpClientConfig {


    @Bean
    HttpClient httpClient() {
        return HttpClient.newBuilder()
          .followRedirects(HttpClient.Redirect.ALWAYS)
          .connectTimeout(Duration.ofSeconds(10))
          .build();
     }
}

We've been getting intermittent timeouts, both on the request and on the connection itself.

We've troubleshooted the network activity and realised that the server we're contacting as a dynamic ip range, effectively change the address for the particular hostname we're contacting.

Would using a single instance of http client cause that kind of issue happening? Would a custom executor help with this scenario?

There isn't much information online regarding connection pooling or managing a connection (unless it's for apache httpclient)

nmarques
  • 151
  • 12
  • Why don't you have a look at the implementation? – Simon Martinelli Feb 27 '20 at 12:36
  • The connection pooling is a bit different for HTTP/1.1 and HTTP/2 - which protocol are you using here? From the description it's not clear whether the issue is that the client reuses an idle connection and that the server has gone away - or if the issue is deeper - that for instance the InetAddress cache contains the stale value. You could try to play around with `-Dnetworkaddress.cache.ttl=` – daniel Mar 02 '20 at 16:59

0 Answers0