Skip to content

WebClient Timeouts and SSL Configuration are incompatible #36263

Closed as not planned
@jjoslet

Description

@jjoslet

I followed the Spring Boot and Spring Framework documentations to configure a WebClient with Spring Boot 3.1.1.

I have

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by anothertheme: http-client-configIssues related to configuration of HTTP clientstheme: sslIssues related to ssl supporttype: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions