![](/img/trans.png)
[英]HystrixRunTimeException: <operation> timed-out and fallback failed
[英]Hystrix command fails with “timed-out and no fallback available”
我注意到我的应用程序中的一些命令失败了
Caused by: ! com.netflix.hystrix.exception.HystrixRuntimeException: GetAPICommand timed-out and no fallback available.
out: ! at com.netflix.hystrix.HystrixCommand.getFallbackOrThrowException(HystrixCommand.java:1631)
out: ! at com.netflix.hystrix.HystrixCommand.access$2000(HystrixCommand.java:97)
out: ! at com.netflix.hystrix.HystrixCommand$TimeoutObservable$1$1.tick(HystrixCommand.java:1025)
out: ! at com.netflix.hystrix.HystrixCommand$1.performBlockingGetWithTimeout(HystrixCommand.java:621)
out: ! at com.netflix.hystrix.HystrixCommand$1.get(HystrixCommand.java:516)
out: ! at com.netflix.hystrix.HystrixCommand.execute(HystrixCommand.java:425)
out: Caused by: ! java.util.concurrent.TimeoutException: null
out: !... 11 common frames omitted
这是我的 Hystrix 配置覆盖:
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=210000
hystrix.threadpool.default.coreSize=50
hystrix.threadpool.default.maxQueueSize=100
hystrix.threadpool.default.queueSizeRejectionThreshold=50
这是什么样的超时? 它是外部应用程序的读取/连接超时吗? 我该如何调试?
这是一个 Hystrix 命令超时,默认情况下每个命令都启用此超时,您可以使用以下属性定义值:
execution.isolation.thread.timeoutInMilliseconds:此属性以毫秒为单位设置时间,在此之后调用者将观察到超时并离开命令执行。 Hystrix 将 > HystrixCommand 标记为 TIMEOUT,并执行回退逻辑。
因此,您可以使用以下属性为您的命令增加超时值或禁用默认超时(如果适用于您的情况):
@HystrixProperty(name = "hystrix.command.default.execution.timeout.enabled", value = "false")
您可以在此处找到更多信息: https : //github.com/Netflix/Hystrix/wiki/Configuration#CommandExecution
可能是您正在调试或连接速度太慢,默认线程执行超时仅为 1 秒,因此如果您在命令中放置断点,您可以轻松收到此消息,假设
虽然这不是你的情况,但可能会帮助别人
查看堆栈跟踪,这是在您上面定义的 210 秒后由 Hystrix 抛出的异常。
因为TimeoutException
是一个检查异常,需要在每个可能抛出此异常的方法上声明。 您会在代码的run()
方法中看到这一点。
您可以像调试任何其他程序一样调试它,但要注意run()
方法在与调用者分开的线程中运行。 210 秒后,尽管您进行了调试会话,调用者仍将继续。
添加以下依赖后
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-javanica</artifactId>
<version>1.5.18</version>
</dependency>
我将能够解决超时问题。
您需要做的是在 application.properties 或 bootstrap.properties 中设置hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=210000
属性
这对我有用,希望能奏效。
您应该增加您的休息客户端 httpclient readTimeout 属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.