How to parse HttpRequestRetryHandler
This article shows you how to analyze HttpRequestRetryHandler, the content is concise and easy to understand, can definitely make your eyes bright, through the detailed introduction of this article, I hope you can get something.
This problem occurs when bulk inserting into a clickhouse database:
21 pool-5-thread-9 28 INFO o.a.http.impl.execchain.RetryExec-I exception O exception (java.net.SocketException) caught when processing request to {}-> http://35.26.59.191:8123: Broken pipe (Write failed) 2128 Retrying request to 02.029 [pool-5-thread-9] INFO o.a.http.impl.execchain.RetryExec-Retrying request to {}-> http://35.26.59.191:8123
Originally: disconnected pipes
18Rd 34INFO o.a.http.impl.execchain.RetryExec 50.032 [pool-11-thread-10] INFO o.a.http.impl.execchain.RetryExec-I exception O exception (java.net.SocketException) caught when processing request to {}-> http://35.26.59.191:8123: > disconnected conduit 18Rd 34INFO o.a.http.impl.execchain.RetryExec 50.033 [pool-11-thread-10] INFO o.a.http.impl.execchain.RetryExec-Retrying request to {}-> http://35.26.59.191:8123
I thought it was because the duration of the connection was too short: (but it didn't work)
Clickhouse.socketTimeout=6000000
After consulting the relevant information, it was found that HttpClient has a default retry strategy.
For get and post in our scenario application, it can be summarized as follows:
Retrying InterruptedIOException, UnknownHostException, ConnectException, and SSLException occurs only when IOExecetion occurs. If an exception occurs, the get method can be retried 3 times, and the post method can be retried 3 times if the output stream corresponding to the socket is not write and flush is successful. First, analyze the exceptions that do not retry:
InterruptedIOException, thread interrupt exception UnknownHostException, cannot find the corresponding host ConnectException, found host but failed to establish a connection. SSLException,https authentication exception. In addition, we often mention two kinds of timeout, connection timeout and read timeout:
Java.net.SocketTimeoutException: Read timed out java.net.SocketTimeoutException: connect timed out these two timeouts are SocketTimeoutException, inherited from InterruptedIOException, belong to the first thread interrupt exception above, and will not be retried.
Because of SocketException extends IOException, I will try again
Summary 1. Retrying 2.InterruptedIOException, UnknownHostException, ConnectException, and SSLException occurs only when IOExecetion occurs. If an exception occurs, the 3.get method can be retried 3 times, and the post method can be retried 3 times if the output stream corresponding to the socket is not write and flush is successful. 4. Read / write timeout does not retry 5.socket transfer is reset or closed will retry 6. And some other IOException can not be analyzed for the time being.
The above content is how to analyze HttpRequestRetryHandler. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.