RetryableException: Read timed out executing導致服務假死無響應

kuroniko發表於2024-05-15

最近發現Plan這個微服務經常會無響應,後來發現是task微服務會呼叫plan的某個介面,經常報錯如下異常,然後time out後又30秒再次發起重試而這個業務處理時間1分鐘-2小時都有可能

所以把plan微服務執行緒池佔滿導致無響應

2024-05-13 14:27:00.282 N/A,b1f2a3468b14468abef240bfeddd8b95,0 [pool-16-thread-5] ERROR c.h.n.c.t.t.TcFileProcessScheduleSendPlanFromOdmToHpJob.fileProcessCronSendPlanFromOdmToHpJob [206] :
feign.RetryableException: Read timed out executing POST http://NOVAPLANSERV/api/v1/plans/syncPlanToOdm
at feign.FeignException.errorExecuting(FeignException.java:277)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:110)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:70)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:96)
at jdk.proxy2/jdk.proxy2.$Proxy163.syncPlanToOdm(Unknown Source)

解決方法:

網上查了很多,試瞭如下配置都無效

feign:
client:
config:
default:
connectTimeout: 60000
readTimeout: 60000


#hystrix的超時時間
hystrix:
command:
default:
execution:
timeout:
enabled: true
isolation:
thread:
timeoutInMilliseconds: 30000


feign.hystrix.enabled: true
hystrix 熔斷機制
hystrix:
shareSecurityContext: true
command:
default:
circuitBreaker:
sleepWindowInMilliseconds: 100000
forceClosed: true
execution:
isolation:
thread:
timeoutInMilliseconds: 600000

#ribbon的超時時間
ribbon:
ReadTimeout: 30000
ConnectTimeout: 30000

後來發現因為我們升級到了最新的springboot

然後使用了最新的openfeign

Spring Cloud OpenFeign 中文文件 (springdoc.cn)

所以應該如下配置:

spring:
cloud:
openfeign:
client:
config:
default:
connectTimeout: 20000000
readTimeout: 20000000
loggerLevel: basic

相關文章