Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to parse HttpRequestRetryHandler

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report