Open
Description
I followed the Spring Boot and Spring Framework documentations to configure a WebClient with Spring Boot 3.1.1.
I have
- configured the SSL following https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#io.rest-client.webclient.ssl
- configured timeouts following https://docs.spring.io/spring-framework/reference/web/webflux-webclient/client-builder.html#webflux-client-builder-reactor-timeout
These configurations are incompatible since they both set the ClientHttpConnector
on the WebClient.Builder
; the second configuration overrides the first one.
Here is a small application to reproduce:
@SpringBootApplication(proxyBeanMethods = false)
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Bean
WebClient webClient(WebClient.Builder builder, WebClientSsl ssl) {
HttpClient httpClient = HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1);
return builder
.clientConnector(new ReactorClientHttpConnector(httpClient)) // TIMEOUT
.apply(ssl.fromBundle("demobundle")) // SSL
.build();
}
@Bean
ApplicationRunner runner(WebClient webClient) {
return new ApplicationRunner() {
@Override
public void run(ApplicationArguments args) throws Exception {
webClient.head()
.uri("https://www.google.com")
.exchangeToMono(r -> Mono.just(r.statusCode()))
.doOnSuccess(System.out::println)
.block();
}
};
}
}
with the following properties:
spring.ssl.bundle.pem.demobundle.key.password=password
spring.ssl.bundle.pem.demobundle.key.alias=alias
In that situation, a timeout does not occur but if I switch // TIMEOUT
with // SSL
lines, a timeout will occur but SSL is no more configured.
I didn't find a proper way to configure this without recreating the full SSL configuration in my application.
Activity
ramanpopli commentedon Jul 13, 2023
Is someone working on it . I would like to contribute on this , but I would request if I can get little more overview on this .
wilkinsona commentedon Jul 13, 2023
Thanks for the offer, @ramanpopli. If you’d like to work on an issue where we provide some guidance, please watch for one labelled as ideal for contribution or, if you haven’t contributed before, first-timers only.
mhalbritter commentedon Sep 18, 2023
If we would make the
org.springframework.boot.autoconfigure.web.reactive.function.client.ReactorClientHttpConnectorFactory.SslConfigurer
public API and add a static method to it:then we could workaround that problem with:
(
SslBundles
can be injected, too)eloo-abi commentedon Nov 6, 2023
mhalbritter commentedon Nov 6, 2023
eloo-abi commentedon Nov 6, 2023
okay..
we have found a workaround/solution maybe
maybe this can be verified if this would be a proper way to configure it?
but i'm not sure if this fits all purposes as this is "globally" then and will also affect nonssl webclients as well
kzander91 commentedon Feb 3, 2024
You're right in that this would be global, affecting all auto-configured
WebClient.Builder
s. I'm in a similar situation to OP in that I have a specificWebClient
that I want to applyWebClientSsl
to and configure it to use a proxy server.In my application I have several other services I need to call and the corresponding
WebClient
instances need to be configured without proxy, so a global configuration viaReactorNettyHttpClientMapper
doesn't work for me...5 remaining items