spring-cloud-openfeign icon indicating copy to clipboard operation
spring-cloud-openfeign copied to clipboard

Feign's connectTimeout and readTimeout deactivates ribbon retries

Open q398544597 opened this issue 5 years ago • 1 comments
trafficstars

In 2.2.2 RELEASE When I configured the Feign readTimeout and connectTimeout, I found that the Ribbon retry didn't work,like this:

ribbon:
  MaxAutoRetries: 2
  MaxAutoRetriesNextServer: 2
  OkToRetryOnAllOperations: true
feign:
  client:
    config:
      default:
        connectTimeout: 2000
        readTimeout: 2000

And then I found in FeignRibbonClientAutoConfiguration through debugging such configuration:

	@Bean
	@ConditionalOnMissingBean
	public Request.Options feignRequestOptions() {
		return LoadBalancerFeignClient.DEFAULT_OPTIONS;
	}

And then the FeignClientFactoryBean#configureUsingConfiguration (), loading the Options:

Request.Options options = getOptional(context, Request.Options.class);
		if (options != null) {
			builder.options(options);
		}

And next in FeignClientFactoryBean#configureUsingProperties(), because I added the timeout configuration, the default Options is now overridden:

if (config.getConnectTimeout() != null && config.getReadTimeout() != null) {
			builder.options(new Request.Options(config.getConnectTimeout(),
					config.getReadTimeout()));
}

Finally, this directly causes me to fail to get the MaxAutoRetries and MaxAutoRetriesNextServer in the Ribbon in the following code:

LoadBalancerFeignClient#getClientConfig()
IClientConfig getClientConfig(Request.Options options, String clientName) {
		IClientConfig requestConfig;
		if (options == DEFAULT_OPTIONS) {
			requestConfig = this.clientFactory.getClientConfig(clientName);
		}
		else {
			requestConfig = new FeignOptionsClientConfig(options);
	   }
		return requestConfig;
}

Obviously, the object here is definitely not DEFAULT_OPTIONS Was it designed that way?

q398544597 avatar Jun 19 '20 11:06 q398544597

@q398544597 will verify it.

OlgaMaciaszek avatar Jul 30 '20 15:07 OlgaMaciaszek

The way it was being handled has been rearchitected and improved since and migrated to work with Spring Cloud LoadBalancer instead of Ribbon. It should have fixed the issue. If you're still experiencing a related issue on the currently supported versions of SC OpenFeign (3.1.6 or 4.0.1, please get back to us).

OlgaMaciaszek avatar Mar 09 '23 13:03 OlgaMaciaszek

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues avatar Mar 16 '23 13:03 spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-cloud-issues avatar Mar 23 '23 13:03 spring-cloud-issues