31

我注意到我的应用程序中的一些命令失败了

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

这是什么类型的超时?是否是外部应用程序的读取/连接超时?我该如何调试呢?

4

5 回答 5

38

这是一个 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

于 2015-11-27T17:24:59.293 回答
17

可能是您处于调试状态或连接速度太慢,默认线程执行超时仅为 1 秒,因此如果您在命令中设置断点,您可以轻松收到此消息

虽然这不是你的情况,但可能会帮助其他人

于 2015-01-29T18:21:16.077 回答
1

Looking at the stacktrace this is an exception thrown by Hystrix after the 210 seconds you defined above.

As TimeoutException is a checked exception that needs to be declared on each method that could throw this exception. You would see this declared in the run() method of your code.

You can debug this like any other program, but be aware that the run() method runs in a thread separate from the caller. After 210 seconds the caller will just continue despite your debugging session.

于 2014-12-09T09:57:29.393 回答
0

添加以下依赖后

   <dependency>
        <groupId>com.netflix.hystrix</groupId>
        <artifactId>hystrix-javanica</artifactId>
        <version>1.5.18</version>
    </dependency>

我将能够解决超时问题。

您需要做的是hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=210000 在 application.properties 或 bootstrap.properties 中设置属性

这对我有用,希望能奏效。

于 2021-01-12T14:35:21.527 回答
-2

你应该增加你的休息客户端 httpclient readTimeout 属性

于 2015-06-04T09:52:22.093 回答