Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
fix: set connection params for webclient
Browse files Browse the repository at this point in the history
Aims to prevent connection closed by client errors
reactor/reactor-netty#1774
  • Loading branch information
ethanmills committed Jan 27, 2023
1 parent d3b41d7 commit 296652d
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -8,6 +8,7 @@ import org.springframework.context.annotation.Configuration
import org.springframework.http.client.reactive.ReactorClientHttpConnector
import org.springframework.web.reactive.function.client.WebClient
import reactor.netty.http.client.HttpClient
import reactor.netty.resources.ConnectionProvider
import java.time.Duration

@Configuration
Expand All @@ -21,7 +22,14 @@ class WebClientConfiguration(

@Bean
fun levApiWebClient(): WebClient {
val httpClient = HttpClient.create().responseTimeout(Duration.ofMinutes(2))
val connectionProvider = ConnectionProvider.builder("levApi")
.maxConnections(100)
.maxIdleTime(Duration.ofSeconds(20))
.maxLifeTime(Duration.ofSeconds(60))
.pendingAcquireTimeout(Duration.ofSeconds(60))
.evictInBackground(Duration.ofSeconds(120))
.build()
val httpClient = HttpClient.create(connectionProvider).responseTimeout(Duration.ofSeconds(10))
return WebClient.builder()
.baseUrl(levApiRootUri)
.clientConnector(ReactorClientHttpConnector(httpClient))
Expand Down

0 comments on commit 296652d

Please sign in to comment.