34

I've noticed that some of the commands in my application fail with

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

This is my Hystrix configuration override:

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=210000
hystrix.threadpool.default.coreSize=50
hystrix.threadpool.default.maxQueueSize=100
hystrix.threadpool.default.queueSizeRejectionThreshold=50

What kind of timeout is this? Is it a read/connection timeout to the external application? How do I go about debugging this?

dkulkarni
  • 2,780
  • 4
  • 27
  • 36

5 Answers5

40

This is a Hystrix Command Timeout, this timeout is enabled by default per each command, you define the value using the property:

execution.isolation.thread.timeoutInMilliseconds: This property sets the time in milliseconds after which the caller will observe a timeout and walk away from the command execution. Hystrix marks > the HystrixCommand as a TIMEOUT, and performs fallback logic.

So you can increase your timeout value or disable the default time out (if apply in your case) for your command using the property:

@HystrixProperty(name = "hystrix.command.default.execution.timeout.enabled", value = "false")

You can find more information here: https://github.com/Netflix/Hystrix/wiki/Configuration#CommandExecution

psantamaria
  • 602
  • 6
  • 17
19

It might be you are in debug or your connection too slow, default thread execution timeout is only 1 second, so you could get this message easily if you put a break-point in your command let's say

Although this is not your case but might help somebody else

xval
  • 301
  • 1
  • 3
2

After adding the following dependency

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

I would be able to resolve the timeout issue.

What you need to do is to set the hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=210000 property in the application.properties or bootstrap.properties

This works for me hopefully would work.

Root
  • 955
  • 1
  • 16
  • 39
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.

ahus1
  • 5,782
  • 24
  • 42
  • My run() method is just a GET HTTP call that looks like this. This is a jersey client. ClientResponse response = client.resource(buildUri()) .get(ClientResponse.class); – dkulkarni Dec 09 '14 at 10:01
  • This is my code. Like I said it is a jersey client@Override protected FetchProvisionedIdsResponse run() throws Exception { ClientResponse response = client.resource(buildUri()) .get(ClientResponse.class); return response.getEntity(MyResponse.class); } – dkulkarni Dec 09 '14 at 10:11
  • You have declared `Exception` in the method, a good style is to narrow it down. From the API description I see that `get()` will throw a `UniformInterfaceException`, but no `TimeoutException`. Therefore it's Hystrix throwing this exception. – ahus1 Dec 09 '14 at 10:54
-2

You should increase ur rest client httpclient readTimeout property

Pushpak Jain
  • 93
  • 2
  • 9