Search code examples
spring-cloudribbonhystrixfeign

Can I Feign clients ConnectTimeout & ReadTimeout override using Ribbon configuration?


First of all, I'm sorry for my bad English.

Can I Feign clients ConnectTimeout & ReadTimeout override using Ribbon configuration?

I don't know how to set 'Feign.client.ReadTimeout' with 'ribbon.readTimeout'.

Below are the relevant my settings.

<serviceId>:
  ribbon:
    ConnectTimeout: 100
    ReadTimeout: 500
    MaxAutoRetriesNextServer: 0

feign:
  client:
    config:
      <commandKey>:
        connectTimeout: 100
        readTimeout: 500

I hope you give an answer to me. 🙏


Solution

  • Use spring boot configuration replacements.

    feign:
      client:
        config:
          <commandKey>:
            connectTimeout: ${<serviceId>.ribbon.ConnectTimeout:100}
            readTimeout: ${<serviceId>.ribbon.ReadTimeout:500}