Feign timeout works but response is returned to the server after timeout + 60''
See original GitHub issueHello,
I am using Ribbon + Feign in a project
@FeignClient(name = "test-proxy")
@RibbonClient(name = "test-proxy")
public interface TestProxy ...
I have set the Feign timeout to 10’’ using the following bit of code:
@Bean
public Request.Options options() {
return new Request.Options(10000, 10000);
}
The timeout works, I get a
feign.RetryableException: Read timed out executing POST...
but the response is not returned until 60’’ afterwards (after about 70’’ in total). The same thing happens if I set the timeout to 5’‘, the response is returned after about 65’'.
It seems there is some thread that is running and stops the response from returning. I read that this might be due to Hystrix thread that waits to time out, but we do not use Hystrix (at least not explicitly).
I tried nevertheless to disable the Hystrix functionality using properties in the application.properties, but to no avail.
Any thoughts on this? Is this a bug or something I am missing?
These are the dependencies I use:
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '1.4.4.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-ribbon', version: '1.4.5.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-client', version: '1.4.4.RELEASE'
compile group: 'org.springframework.cloud', name: 'spring-cloud-dependencies', version: 'Edgware.RELEASE', ext: 'pom'
runtime('org.springframework.boot:spring-boot-devtools')
}
Thank you
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Related StackOverflow Question
@girionis A
javax.net.ssl.HttpsURLConnectionand its methods are used underneath by Feign. The timeout is set on the connection viaconnection.setReadTimeout(...). If it’s exceeded, a standardjava.net.SocketTimeoutExceptionis thrown, which is caught inSynchronousMethodHandlerin Feign straight away and wrapped inFeignExceptionwhich you are catching inTestProxyControllerand yourresResponseEntityis returned straight away as per your implementation and its further handled by Spring WebMVC and not by any Spring Cloud project, so that’s not an issue pertaining to Ribbon or Feign. However, what is probably causing the delay in the demo that you have provided is setting0asHttpStatusinres. If you build aResponseEntitywith a standardHttpStatus, like so:res1 = ResponseEntity.ok(e.getMessage());you will see that there is no additonal wait.I got the same problem . I set the test url to return in 3s,and set the read-timeout value 2s. the timeout mechanism is work but the exception will be thrown after about 10s. So i think the reason is that feign have already retried a lot of times. and the Exception will throw after 2s which i expected after I set the retryer Retryer.NEVER_RETRY.