Reputation: 3609
We are using Spring WebClient with the following settings
Config:
http-connection-config:
max-idle-time-seconds: 25
max-life-time-seconds: 60
evict-in-background-seconds: 120
Code:
ConnectionProvider provider = ConnectionProvider.builder("fixed")
.maxIdleTime(Duration.ofSeconds(connectionProviderConfig.getMaxIdleTimeSeconds()))
.maxLifeTime(Duration.ofSeconds(connectionProviderConfig.getMaxLifeTimeSeconds()))
.evictInBackground(Duration.ofSeconds(connectionProviderConfig.getEvictInBackgroundSeconds())).build();
builder = builder.clientConnector(new ReactorClientHttpConnector(HttpClient.create(provider)));
And seeing an intermittent error which seems to happen when the traffic increases
Caused by: reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response
Suppressed: org.springframework.web.reactive.function.client.WebClientRequestException: Connection prematurely closed BEFORE response
Caused by: java.util.concurrent.CompletionException: RestCallFailedException(super=com.tmobile.genesis.common.integration.framework.exception.RestCallFailedException, code=SILCC0015, userMessage=Error on System API call out, systemMessage=Connection prematurely closed BEFORE response, detailLink=)
The question is will this maxLifeTime
cause the connection to be closed even if it's being used in an active request? Meaning if the connection is 55 seconds old and gets used for an API call, it be closed after 60 seconds even for an inflight request?
These 3 configs are mentioned everywhere to resolve connection related errors. It did resolve a few issues but might have introduced some more.
When looking at logs on the server side, it showed timeout after 5-9 seconds even though the server timeout is 10 seconds indicating the client closed the connection.
Upvotes: 0
Views: 204