Feign timeout works but response is returned to the server after timeout + 60''

See original GitHub issue

Hello,

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:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
OlgaMaciaszekcommented, Nov 2, 2018

@girionis A javax.net.ssl.HttpsURLConnection and its methods are used underneath by Feign. The timeout is set on the connection via connection.setReadTimeout(...) . If it’s exceeded, a standard java.net.SocketTimeoutException is thrown, which is caught in SynchronousMethodHandler in Feign straight away and wrapped in FeignException which you are catching in TestProxyController and your res ResponseEntity is 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 setting 0 as HttpStatus in res. If you build a ResponseEntity with a standard HttpStatus, like so: res1 = ResponseEntity.ok(e.getMessage()); you will see that there is no additonal wait.

0reactions
HaoChoucommented, Oct 25, 2019

Hello @girionis I have tried reproducing it and it did work the way you describe it in Postman, however, while using different http clients, I got the response straight away, which is why I would assume the issue is with Postman rather than with Feign/ Ribbon. Please try using a different http client, such as httpie and let me know if you still have any issues.

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. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve Timeout FeignClient - java - Stack Overflow
I'm using Feign.builder() to instantiate my Feign clients. In order to set connectTimeout and readTimeout , I use the following :
Read more >
Spring Cloud OpenFeign
readTimeout is applied from the time of connection establishment and is triggered when returning the response takes too long. In case the server...
Read more >
Integration Tests With Spring Cloud Netflix and Feign - Baeldung
Let's explore how we can do integration testing of a Feign Client. ... this setup to make sure our entire configuration works as...
Read more >
Why do I get "Unexpected end of file from server ... - MathWorks
I was calling my MPS through a load balancer and the load balancer had an idle timeout set to 60 seconds. It was...
Read more >
Index (Feign Core 10.9.1 API) - javadoc.io
Connect Timeout Value. connectTimeoutMillis() - Method in class feign.Request.Options ... if retry is permitted, return (possibly after sleeping).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found