Skip to content

Commit c23f06e

Browse files
committed
add example in the docs on how to use the HttpClientConnectionManagerBuilderCustomizer, as it already exists for httpClient5FeignConfiguration.HttpClientBuilderCustomizer a few lines above
Signed-off-by: Severin Kistler <kistlerseverin@gmail.com>
1 parent 48be6e1 commit c23f06e

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

docs/modules/ROOT/pages/spring-cloud-openfeign.adoc

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,13 @@ When it comes to the Apache HttpClient 5-backed Feign clients, it's enough to en
144144
You can customize the HTTP client used by providing a bean of either `org.apache.hc.client5.http.impl.classic.CloseableHttpClient` when using Apache HC5.
145145

146146
You can further customise http clients by setting values in the `spring.cloud.openfeign.httpclient.xxx` properties. The ones prefixed just with `httpclient` will work for all the clients, the ones prefixed with `httpclient.hc5` to Apache HttpClient 5, and the ones prefixed with `httpclient.http2` to Http2Client. You can find a full list of properties you can customise in the appendix.
147-
If you can not configure Apache HttpClient 5 by using properties, there is an `HttpClient5FeignConfiguration.HttpClientBuilderCustomizer` interface for programmatic configuration. Similarly, to configure the `HttpClientConnectionManager`, you can use `HttpClient5FeignConfiguration.HttpClientConnectionManagerBuilderCustomizer`.
147+
If you can not configure Apache HttpClient 5 by using properties, there is an `HttpClient5FeignConfiguration.HttpClientBuilderCustomizer` interface for programmatic configuration. Similarly, to configure the `HttpClientConnectionManager`, you can use `HttpClient5FeignConfiguration.HttpClientConnectionManagerBuilderCustomizer`. Both usages are shown in the example below.
148148

149149
TIP: Apache HTTP Components `5.4` have changed defaults in the HttpClient relating to HTTP/1.1 TLS upgrades. Most proxy servers handle upgrades without issue, however, you may encounter issues with Envoy or Istio. If you need to restore previous behaviour, you can use `HttpClient5FeignConfiguration.HttpClientBuilderCustomizer` to do it, as shown in the example below.
150150

151151
[source,java,indent=0]
152152
----
153-
@Configuration
154-
public class FooConfiguration {
153+
public class HttpClientConfiguration {
155154
156155
@Bean
157156
public HttpClient5FeignConfiguration.HttpClientBuilderCustomizer httpClientBuilder() {
@@ -164,6 +163,24 @@ public class FooConfiguration {
164163
}
165164
----
166165

166+
TIP: Apache HTTP Components `5.5.1` have changed defaults in the HttpClient relating to TLS handshake timeouts. An unset TLS handshake timeout is now implicitly bound by the `connectTimeout` while it was unbounded previously. To restore previous defaults, you can use `HttpClient5FeignConfiguration.HttpClientBuilderCustomizer` to do it, as shown in the example below.
167+
168+
[source,java,indent=0]
169+
----
170+
public class HttpClientConnectionManagerConfiguration {
171+
172+
@Bean
173+
public HttpClient5FeignConfiguration.HttpClientConnectionManagerBuilderCustomizer httpClientConnectionManagerBuilder() {
174+
return (httpClientConnectionManagerBuilder) -> {
175+
TlsConfig.Builder tlsConfigBuilder = TlsConfig.custom();
176+
// 0 seconds timeout means infinite
177+
tlsConfigBuilder.setHandshakeTimeout(Timeout.of(0, TimeUnit.SECONDS));
178+
httpClientConnectionManagerBuilder.setDefaultTlsConfig(tlsConfigBuilder.build());
179+
};
180+
}
181+
}
182+
----
183+
167184
TIP: Starting with Spring Cloud OpenFeign 4, the Feign Apache HttpClient 4 is no longer supported. We suggest using Apache HttpClient 5 instead.
168185

169186
Spring Cloud OpenFeign _does not_ provide the following beans by default for feign, but still looks up beans of these types from the application context to create the Feign client:

0 commit comments

Comments
 (0)