title: Spring Cloud Feign client with Hystrix circuit-breaker timeout defaults in 2 seconds
body: <p><strong>Reproducible through a project on GitHub: <a href="https://github.com/Nikolas-Charalambidis/spring-cloud-feign-hystrix-timeout-problem" rel="nofollow noreferrer">spring-cloud-feign-hystrix-timeout-problem</a></strong></p>
  <hr />
  <p>I am using Spring Boot <code>2.3.1.RELEASE</code> with Spring Cloud <code>Hoxton.SR6</code>. Namely Feign client and Hystrix without Zuul and Eureka to fetch REST responses.</p>
  <pre><code>&lt;dependency&gt;
     &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
     &lt;artifactId&gt;spring-cloud-dependencies&lt;/artifactId&gt;
     &lt;version&gt;Hoxton.SR6&lt;/version&gt;
     &lt;type&gt;pom&lt;/type&gt;
     &lt;scope&gt;import&lt;/scope&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>Then I use use the following  dependencies on top of Spring Boot <code>2.3.1.RELEASE</code> and <code>Spring Cloud Hoxton.SR6</code>:</p>
  <ul>
  <li><code>org.springframework.boot</code>:<code>spring-boot-starter</code></li>
  <li><code>org.springframework.boot</code>:<code>spring-boot-starter-web</code></li>
  <li><code>org.springframework.cloud</code>:<code>spring-cloud-starter-openfeign</code></li>
  <li><code>org.springframework.cloud</code>:<code>spring-cloud-starter-netflix-hystrix</code></li>
  </ul>
  <p>I enable <code>@EnableFeignClients</code> and <code>@EnableCircuitBreaker</code> and use a <code>@FeignClient</code> with a simple fallback to log and rethrow an exception:</p>
  <pre><code>@FeignClient(name=&quot;my-feign&quot;, url = &quot;${feign.url}&quot;, fallbackFactory = MyFallbackFactory.class) {
  public interface MyFeignClient {
  
      @PostMapping(value = &quot;/api/dto&quot;)
      postDto(@RequestBody Dto dto);
  }
  </code></pre>
  <p>With the following <code>application.yml</code> the timeout is around <strong>1 second</strong> because Hystrix defaults to the very same value:</p>
  <pre><code>feign:
    hystrix:
      enabled: true
    client:
      config:
        default:
          connectTimeout: 5000
          readTimeout: 5000
  </code></pre>
  <blockquote>
  <p>11:52:05.493 INFO  10200 --- [nio-8060-exec-2] com.mycompany.rest.MyController       : Calling REST right now!</p>
  <p>11:52:06.538 ERROR 24044 --- [nio-8060-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: MyFeignClient#postDto(Dto) timed-out and fallback failed.] with root cause</p>
  </blockquote>
  <hr />
  <p><strong>What I tried?</strong></p>
  <p>As long as I add the following lines to increase the timeouts to 60 seconds, the timeout become effectively around <strong>2 seconds</strong>:</p>
  <pre><code>hystrix:
    command:
      default:
        execution:
          timeout:
            enabled: true
          isolation:
            thread:
              timeoutInMilliseconds: 60000
  </code></pre>
  <blockquote>
  <p>11:53:33.590  INFO 16052 --- [nio-8060-exec-2] com.mycompany.rest.MyController       : Calling REST right now!</p>
  <p>11:53:35.614 ERROR 16052 --- [nio-8060-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: MyFeignClient#postDto(Dto) failed and fallback failed.] with root cause</p>
  </blockquote>
  <p>The call falls into fallback right in <strong>2 seconds</strong> as long as the Hystrix read/connect timeouts have been increased. However I expect to achieve <strong>5 seconds</strong> as long as I declared it in <code>feign.client.config.default...</code> timeouts. I feel I am missing another configuration.</p>
  <p><strong>Q: How to increase the timeout?</strong></p>
  <hr />
  <p><strong>Edit:</strong></p>
  <ul>
  <li><code>mvn dependency:tree</code>: <a href="https://pastebin.com/LJFGaMTc" rel="nofollow noreferrer">https://pastebin.com/LJFGaMTc</a></li>
  <li><code>pom.xml</code>: <a href="https://pastebin.com/98uXHTaR" rel="nofollow noreferrer">https://pastebin.com/98uXHTaR</a></li>
  <li>Stack-trace: <a href="https://pastebin.com/7rQweC8w" rel="nofollow noreferrer">https://pastebin.com/7rQweC8w</a></li>
  </ul>