SoFunction
Updated on 2025-04-10

OpenFeign timeout time setting does not take effect problem troubleshooting record

Troubleshooting the OpenFeign timeout time setting does not take effect

Recently, when springboot 3 was upgraded, I suddenly found that the timeout setting of openFeign in the configuration file was not effective.

Previous configuration

as follows:

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

Searching information all involves the problem of setting timeout of ribbon or hystrix, but it is not. There is no way, look at the source code, in the FeignClientFactoryBean class

protected void configureFeign(FeignClientFactory context,  builder) {
    FeignClientProperties properties =  != null ? (FeignClientProperties)() : (FeignClientProperties)();
    FeignClientConfigurer feignClientConfigurer = (FeignClientConfigurer)(context, );
    (());
    if (properties != null && ) {
        if (()) {
            (context, builder);
            (()().get(()), builder);
            (()().get(), builder);
        } else {
            (()().get(()), builder);
            (()().get(), builder);
            (context, builder);
        }
    } else {
        (context, builder);
    }

}

You can see that the configuration is read from FeignClientProperties

After finishing, enter this class and find the annotation

@ConfigurationProperties("")

Compared with previous versions, the annotation of this class is

@ConfigurationProperties("")

So the problem is obvious, change the configuration to

spring:
  cloud:
    openfeign:
      client:
        config:
          default:
            connectTimeout: 3000
            readTimeout: 5000

Problem solving

Say a few more words, in fact, in addition to looking at the source code, it may be more direct to looking at the official website directly.

/spring-cloud-openfeign/docs/current/reference/html/#timeout-handling

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.