Konrad Windszus created HTTPCLIENT-2282:
-------------------------------------------
Summary: Handle java.net.SocketException: Connection reset more
gracefully
Key: HTTPCLIENT-2282
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2282
Project: HttpComponents HttpClient
Issue Type: Improvement
Components: HttpClient (classic)
Affects Versions: 4.5.14
Reporter: Konrad Windszus
Currently in edge cases the retry mechanism leveraging
DefaultHttpRequestRetryHandler does not catch "Connection reset" exceptions.
This is caused by
# A connection pool which keeps the connections alive for too long
# The reduced default validation of connections in
https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.html:
"The code now only checks the connection if the elapsed time since the last
use of the connection exceeds the timeout that has been set. The default
timeout is set to 2000ms"
The error scenario is as follows:
# A client opens a number of connection almost in parallel which exceed the
number of retries
# then the connections are reused shortly before they are closed silently by
some proxy or the server.
# Now the client tries to reuse those but runs into the "Connection reset"
issue. Although it will retry through DefaultHttpRequestRetryHandler 3
different pooled connections they all suffer from the fact that they are not
longer accepted (and therefore throw the same SocketException).
Maybe one could improve the resilience by calling
https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.html#setValidateAfterInactivity(int)
with 0 on the underlying connection pool manager until a connection is
successfully established to that host again.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]