How to solve Timeout FeignClient

feign client timeout not working
what is feign client in microservices
feign client async call
feign response interceptor
feign decoder
feign client url
feignclient github
feign client post mapping

My application is getting below error when consuming a service that performs queries in SQL Server using FeignClient.

ERROR:

Exception in thread "pool-10-thread-14" feign.RetryableException: Read timed out executing GET http://127.0.0.1:8876/processoData/search/buscaProcessoPorCliente?cliente=ELEKTRO+-+TRABALHISTA&estado=SP

My Consumer Service:

@FeignClient(url="http://127.0.0.1:8876")
public interface ProcessoConsumer {

@RequestMapping(method = RequestMethod.GET, value = "/processoData/search/buscaProcessoPorCliente?cliente={cliente}&estado={estado}")
public PagedResources<ProcessoDTO> buscaProcessoClienteEstado(@PathVariable("cliente") String cliente, @PathVariable("estado") String estado);

}

My YML:

server:
  port: 8874

endpoints:
  restart:
    enabled: true
  shutdown:
    enabled: true
  health:
    sensitive: false

eureka:
  client:
  serviceUrl:
    defaultZone: ${vcap.services.eureka-service.credentials.uri:http://xxx.xx.xxx.xx:8764}/eureka/
  instance: 
    preferIpAddress: true

ribbon:
  eureka:
    enabled: true

spring:
  application:
    name: MyApplication
  data:
    mongodb:
      host: xxx.xx.xxx.xx
      port: 27017
      uri: mongodb://xxx.xx.xxx.xx/recortesExtrator
      repositories.enabled: true
    solr:
      host: http://xxx.xx.xxx.xx:8983/solr
      repositories.enabled: true

Anyone know how to solve this?

Thanks.

Add below properties in Application.properties file.

feign.client.config.default.connectTimeout: 160000000
feign.client.config.default.readTimeout: 160000000

Hi, I would like to ask if it's possible to set different timeout policies for different methods in the same feign client. client, but also be a part of MethodMetadata, and a Contract implemention can resolve the Options per method. i find HystrixFeign just use FeignClient's configuration , so the HystrixCommand's timeout then the FeignClient's timeout config? Sign up for free to join this conversation on GitHub . Already have an account?

just ran into this issue as well. As suggested by @spencergibb here is the workaround I'm using. See the link

Add these in the application.properties.

# Disable Hystrix timeout globally (for all services)
hystrix.command.default.execution.timeout.enabled: false

# Increase the Hystrix timeout to 60s (globally)
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000

Add this in the Java configuration class.

import feign.Request;

@Configuration
@EnableDiscoveryClient
@EnableFeignClients(basePackageClasses = { ServiceFeignClient.class })
@ComponentScan(basePackageClasses = { ServiceFeignClient.class })
public class FeignConfig {

    /**
     * Method to create a bean to increase the timeout value, 
     * It is used to overcome the Retryable exception while invoking the feign client.
     * @param env,
     *            An {@link ConfigurableEnvironment}
     * @return A {@link Request}
     */
    @Bean
    public static Request.Options requestOptions(ConfigurableEnvironment env) {
        int ribbonReadTimeout = env.getProperty("ribbon.ReadTimeout", int.class, 70000);
        int ribbonConnectionTimeout = env.getProperty("ribbon.ConnectTimeout", int.class, 60000);

        return new Request.Options(ribbonConnectionTimeout, ribbonReadTimeout);
    }
}

SOLUTION 1 : Add below properties in Application.yml file. feign: client: config: default: connectTimeout: 80000000 readTimeout  Spring will handle the wiring for you based on the fact that you annotated your feign client with the @FeignClient annotation. This way you can modify the behavior from the wrapper class. You'd write your fallback logic in a method and call the feign client as needed.

I'm using Feign.builder() to instantiate my Feign clients.

In order to set connectTimeout and readTimeout, I use the following :

Feign.builder()
     ...
     .options(new Request.Options(connectTimeout, readTimeout))
     .target(MyApiInterface.class, url);

Using this I can configure different timeout for different APIs.

If your application is a Eureka client then it will resolve the service in the Eureka feign: client: config: feignName: 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.

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=6000
ribbon.ReadTimeout=60000
ribbon.ConnectTimeout=60000

make sure ribbon's timeout is bigger than hystrix

At this point, if it times out, report the error: Default Hystrix timeout configuration: Hystrix. In order to avoid timeout, we can configure our own timeout according to​  I see the same timeout values being applied to all clients. I am using this with ribbon and okhttp. Am I doing something wrong here? ServiceALongRunningClient.java: @FeignClient(name = "test-service", decode404 = true, configuration = LongRunningClientConfiguration.class) public interface ServiceALongRunningClient extends ServiceA {

Look at this answer. It did the trick for me. I also did a bit of research and I've found the properties documentation here:

https://github.com/Netflix/Hystrix/wiki/Configuration#intro

tags: Read timed out executing POST Feign timeout setting feign read timeout getResponseCode(HttpURLConnection.java:480) at feign.Client$Default. solution. First, let's take a look at Feign's introduction. Feign is a declarative web  Yes, is what i've done, i was wondering if there is a way to instrument both feign timeout and hystrix timeout with the same property because i have three different clients in my service all of them with hystrix and i wasn't able to find a way to set a "per client" hystrix timeout config

Add below properties in Application.properties file. feign.client.config.default.​connectTimeout: 160000000 feign.client.config.default.readTimeout: 160000000. The com.netflix.loadbalancer.LoadBalancerContext takes the original protocol from the @FeignClient definition so if you want to use https you can specify that with (as discussed in #337) @FeignClient("https://users") It would be very helpful to support placeholder here so that you can have different schemes in various landscapes:

Now we can use the feign config in Feign Client annotation, as show below. FooClient.kt. @FeignClient(value = "foo-client", url = "http://  How to customize un certain number of @FeignClient with overiding configuration attribute on each configuration. My usecase is for n FeignClient, I want one specific RequestInterceptor (like add a token) for m another FeignClient, I want

class FeignConfig { /** * Method to create a bean to increase the timeout value, * It is used to overcome the Retryable exception while invoking the feign client. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Setting request timeout with Netflix Feign and Hystrix

Comments
  • Hey Renan, after which time you get a timeout error and how long does a call to the backend usually take?
  • Why your Feign client says port 8876 but your YML configuration says port 8874?
  • Having tried all sort of black magic with properties consisting of Hystrix, ribbon and what not, this is the cleanest (and working) solution that I have encountered.
  • The catch is that both need to be set for either of them to take effect. 🤷🏽‍♂️ Here's the relevant source
  • Thanks. I don't use Hystrix, and all other suggestions to use ribbon.Read and Connect Timeout didn't work for me. But adding this bean solved it.
  • That should be exactly vice versa: "When using Hystrix commands that wrap Ribbon clients you want to make sure your Hystrix timeout is configured to be longer than the configured Ribbon timeout, including any potential retries that might be made. For example, if your Ribbon connection timeout is one second and the Ribbon client might retry the request three times, than your Hystrix timeout should be slightly more than three seconds." cloud.spring.io/spring-cloud-netflix/single/…