How to set custom Feign client connection timeout?

后端 未结 2 1135
离开以前
离开以前 2021-02-03 11:48

I have Spring Boot application with this Gradle dependencies:

compile(\"org.springframework.cloud:spring-cloud-starter-eureka\")
compile(\"org.springframework.cl         


        
相关标签:
2条回答
  • 2021-02-03 12:32

    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.

    0 讨论(0)
  • 2021-02-03 12:44

    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

    0 讨论(0)
提交回复
热议问题