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 troubleshoot the timeout exception of online SpringCloud Feign request service

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Today, the editor will share with you the relevant knowledge points about how to troubleshoot offline SpringCloud Feign request service timeout anomalies. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Due to the recent surge in online single volume, the third party reported that some of the work order business had query processing failure. After troubleshooting, the current system failed to call the downstream system through FeignClient (the exception code is posted below).

Caused by: feign.RetryableException: Read timed out executing POST http://xxxx

At feign.FeignException.errorExecuting (FeignException.java:84) ~ [feignMuir Corremuri 10.1.0.jarhammer raceme Vera]

At feign.SynchronousMethodHandler.executeAndDecode (SynchronousMethodHandler.java:113) ~ [feignMuir Corremuri 10.1.0.jarhammer raceme Vera]

At feign.SynchronousMethodHandler.invoke (SynchronousMethodHandler.java:78) ~ [feignMuir Corremuri 10.1.0.jarhammer raceme Vera]

At feign.ReflectiveFeign$FeignInvocationHandler.invoke (ReflectiveFeign.java:103) ~ [feignMuir Corremuri 10.1.0.jarhammer raceme Vera]

At com.sun.proxy.$Proxy141.creditReportConvert (Unknown Source) ~ [na:na]

Caused by: java.net.SocketTimeoutException: Read timed out

At java.net.SocketInputStream.socketRead0 (Native Method) ~ [na:1.8.0_121]

At java.net.SocketInputStream.socketRead (SocketInputStream.java:116) ~ [na:1.8.0_121]

At java.net.SocketInputStream.read (SocketInputStream.java:171) ~ [na:1.8.0_121]

At java.net.SocketInputStream.read (SocketInputStream.java:141) ~ [na:1.8.0_121]

At java.io.BufferedInputStream.fill (BufferedInputStream.java:246) ~ [na:1.8.0_121]

At java.io.BufferedInputStream.read1 (BufferedInputStream.java:286) ~ [na:1.8.0_121]

At java.io.BufferedInputStream.read (BufferedInputStream.java:345) ~ [na:1.8.0_121]

At sun.net.www.http.HttpClient.parseHTTPHeader (HttpClient.java:704) ~ [na:1.8.0_121]

At sun.net.www.http.HttpClient.parseHTTP (HttpClient.java:647) ~ [na:1.8.0_121]

At sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1569) ~ [na:1.8.0_121]

At sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1474) ~ [na:1.8.0_121]

At java.net.HttpURLConnection.getResponseCode (HttpURLConnection.java:480) ~ [na:1.8.0_121]

At feign.Client$Default.convertResponse (Client.java:143) ~ [feignMuycoremure 10.1.0.jarhammer raceme Vera]

At feign.Client$Default.execute (Client.java:68) ~ [feignMuycoremure 10.1.0.jarhammer raceme Vera]

At org.springframework.cloud.openfeign.ribbon.FeignLoadBalancer.execute (FeignLoadBalancer.java:93) ~ [springcopyright cloudlyopenfeignMuscoreMusure 2.1.1.RELEASE.jar colors and Release 2.1.1.RELEASE]

At org.springframework.cloud.openfeign.ribbon.FeignLoadBalancer.execute (FeignLoadBalancer.java:56) ~ [springcopyright cloudlyopenfeignMuscoreMusure 2.1.1.RELEASE.jar colors and Release 2.1.1.RELEASE]

At com.netflix.client.AbstractLoadBalancerAwareClient$1.call (AbstractLoadBalancerAwareClient.java:104) ~ [Ribbonmuri loadbalancerMuth2.3.0.jarring plugo 2.3.0]

At com.netflix.loadbalancer.reactive.LoadBalancerCommand$3 $1.call (LoadBalancerCommand.java:303) ~ [Ribbonmuri loadbalancerly2.3.0.jarfuzhiplu 2.3.0]

Through the system slow request to capture and intercept, it is found that the current request takes only 1031 milliseconds to trigger a Read timed out timeout error. Both this project and downstream projects are registered on Eureka. They are confused about this 1-second timeout, so they start to consult the underlying source code.

Through the trace code, you can configure the connection timeout for 10 seconds and the read timeout for 60 seconds by default in the feign.Request internal class Options constructor. However, the call request took only about 1 second to be disconnected and the timeout error was prompted. It is preliminarily determined that the default timeout configuration does not take effect.

At this point, let's review the complete invocation process steps of the Feign link.

You can see that Feign calls are divided into two layers: Hystrix and Ribbon. Generally speaking, the high version of Hystrix is disabled by default. (for this project, Hystrix is disabled by default, so now you need to analyze the configuration information of Ribbon layer calls)

You can see that the read timeout and connection timeout configured by RibbonClientConfiguration by default are 1000 milliseconds = 1 second. If no timeout is configured, the current timeout is consistent with the timeout error triggered by this call.

You can see the override timeout when IClientConfig is empty in the execute method of FeignLoadBalancer. The default is the timeout of Ribbon, not the default timeout of Feign Options.

Public FeignLoadBalancer (ILoadBalancer lb, IClientConfig clientConfig, ServerIntrospector serverIntrospector) {super (lb, clientConfig); this.setRetryHandler (RetryHandler.DEFAULT); this.clientConfig = clientConfig; this.ribbon = RibbonProperties.from (clientConfig); RibbonProperties ribbon = this.ribbon; this.connectTimeout = ribbon.getConnectTimeout (); this.readTimeout = ribbon.getReadTimeout (); this.serverIntrospector = serverIntrospector;}

If there is a configured timeout in the application.properties file, the configured timeout is used. Otherwise, it takes the default timeout of Ribbon, that is, the default time for Feign to call the service on the Internet is 1 second, that is, if there is no connection for more than 1 second or no response for more than 1 second, an error will be reported accordingly.

If the response time of a service in the actual business exceeds 1 second, we can configure the corresponding timeout according to the actual response situation. The configurations of properties and yml versions are posted below.

# properties version feign.client.config.default.connectTimeout=60000feign.client.config.default.readTimeout=60000#yml version feign: client: config: default: connectTimeout: 60000 readTimeout: 60000 is all the contents of the article "how to troubleshoot the timeout exception of online SpringCloud Feign request service". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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

Development

Wechat

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

12
Report