Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
We are using
Spring Boot 2.0.0.RELEASE
with
spring-cloud-starter-netflix-ribbon
for our micro services. I set
ribbon.readTimeout=1000
for slow requests and check it with our micro service setting breakpoint inside
@GetMapping
method without sending a response. In my test I have been waiting for 10 minutes and did not get any exception. It seems like there is no readTimeout at all.
Service configuration
ribbon:
ReadTimeout: 1000
my-service:
ribbon:
eureka:
enabled: false
listOfServers: localhost:8080
ReadTimeout: 1000
ConnectTimeout: 1000
The only way a can make it work is ribbon.restclient.enabled=true
. But this client is deprecated and I don't wont to use it.
Not all the ribbon properties are supported by spring-cloud-netflix while being used with a Spring RestTemplate
. There are some ribbon properties that work, as described in the docs, but ReadTimeout
is not one of them. So it does not work, but it's by desing (as per the response to this issue). However, if you are using Spring's RestTemplate
, you can set it there directly, like so:
@LoadBalanced
@Bean
RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder
.setReadTimeout(2000)
.build();
–
–
–
I think you need to configure Hystrix timeouts. Take a look at this part of the documentation : http://cloud.spring.io/spring-cloud-static/Edgware.RELEASE/single/spring-cloud.html#_hystrix_timeouts_and_ribbon_clients
It could be something like that :
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 1100
ribbon:
ConnectTimeout: 1000
ReadTimeout: 1000
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
However, we use ribbon via feign, in a client as so:
@FeignClient(value = "serviceA")
public interface ServiceAClient {
@GetMapping(value = "/test")
String getTest();
We then use a wiremock test to introduce a fixed delay above the read timeout to verify it is working fine.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.