javaspringspring-cloud-netflixspring-cloud-feign

Can't configure Feign Client timeouts


I'm using Feign Client with disabled Load Balancer

@FeignClient(name = "my-client", url = "${myHost}", configuration = ClientContext.class)

So, all ribbon properties are ignored. I'm trying to set custom timeouts by different ways, but Feign ignores all them and throws TimeoutException after 60 seconds. Ways I tried to use: in ClientContext: 1)

@Value("${feign.connectTimeout:10000}")
private int connectTimeout;

@Value("${feign.readTimeOut:300000}")
private int readTimeout;

@Bean
public Request.Options options() {
    return new Request.Options(connectTimeout, readTimeout);
}

2)

@Bean
public Request.Options options() {
    return new Request.Options(10_000, 300_000);
}

in bootstrap.properties file: 1)

feign.client.default.connect-timeout=10000
feign.client.default.read-timeout=300000

2)

feign.client.default.config.connect-timeout=10000
feign.client.default.config.read-timeout=300000

3)

feign.client.default.connectTimeout=10000
feign.client.default.readTimeout=300000

4)

feign.client.default.config.connectTimeout=10000
feign.client.default.config.readTimeout=300000

Error stack trace is:

Error Message: feign.RetryableException: Read timed out executing GET http://myrequest...
Stacktrace: 
feign.FeignException.errorExecuting(FeignException.java:67)
feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:10)
feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)

Can you suggest me right configuration or found what is wrong in code blocks above?


Solution

  • The right solution was

    @Value("${feign.connectTimeout:10000}")
    private int connectTimeout;
    
    @Value("${feign.readTimeOut:300000}")
    private int readTimeout;
    
    @Bean
    public Request.Options options() {
        return new Request.Options(connectTimeout, readTimeout);
    }
    

    and add to .properties file this one payer-service-client.feign.hystrix.enabled=false