9

I have Spring Boot application with this Gradle dependencies:

compile("org.springframework.cloud:spring-cloud-starter-eureka")
compile("org.springframework.cloud:spring-cloud-starter-feign")
compile("org.springframework.cloud:spring-cloud-starter-ribbon")
compile("org.springframework.cloud:spring-cloud-starter-hystrix")
compile("org.springframework.cloud:spring-cloud-starter-config")

Also I have Feign client:

@FeignClient(name = "client")
public interface FeignService {

    @RequestMapping(value = "/path", method = GET)
    String response();

}

My application.properties:

client.ribbon.listOfServers = http://localhost:8081
ribbon.eureka.enabled=false

When query time is more than 1 second I get exception:

com.netflix.hystrix.exception.HystrixRuntimeException: response timed-out and no fallback available.

So my question is: how can I set custom Feign client connection timeout? For example to 2 seconds.

Roman Cherepanov
  • 1,440
  • 1
  • 20
  • 38

2 Answers2

18

I solved my problem using this answer on question: Hystrix command fails with “timed-out and no fallback available”.

I added hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=4000 to my application.properties to set custom timeout.

Community
  • 1
  • 1
Roman Cherepanov
  • 1,440
  • 1
  • 20
  • 38
1

You can be configured timeout using configuration properties on application.yaml file:

feign:
  client:
    config:
      default:
        connectTimeout: 5000
        readTimeout: 5000

Notice that this will change your default feign configuration, if you want to update the timeouts just for your client replace default with the name configured in @FeignClient in your case it will be client, another thing is that you must specify both connectTimeout and readTimeout for this to take effect.

For more detail see this: documentation

Yoni
  • 275
  • 1
  • 16