spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.52k stars 3.32k forks source link

Resilience4J timelimiter.timeoutDuration not taken into account #2449

Closed alampada closed 2 years ago

alampada commented 2 years ago

Describe the bug

Spring boot version used:2.6.0 Spring cloud version used: 2021.0.0-RC1

This is also reproducible with older versions such as spring boot 2.5.7 and spring cloud 2020.0.4

I am trying to add a CircuitBreaker for a route and I'd like to override the default(?) timeout of 1 second. To configure the CircuitBreaker I am following the spring cloud gateway docs the spring cloud circuit breaker docs

I hope I haven't made any mistakes in the configurations. However, the circuit breaker times out after 1 second instead of 2 seconds as set in application.yml. Please refere to the sample application below for more details.

Sample This is a project I created to demo the issue: https://github.com/alampada/spring-cloud-gateway-resilience4j

Update: Please ignore the issue was not setting up application.yml correctly:

resilience4j.circuitbreaker:
  instances:
    httpBinCircuitBreaker:
      registerHealthIndicator: true
      slidingWindowSize: 10
      minimumNumberOfCalls: 10
resilience4j.timelimiter:
  instances:
    httpBinCircuitBreaker:
      timeoutDuration: 4s
ctlove0523 commented 2 years ago

@alampada your configure file format not correct,i hava make issue in your repository for this.

ctlove0523 commented 2 years ago

@alampada your config in this issue is correct but error in your repository.

dragontree101 commented 2 years ago

i have the same question? it's bug or config error? @alampada @ctlove0523

dragontree101 commented 2 years ago

i debug the code, i found maybe bug in TimeLimiterConfiguration#timeLimiterRegistry it seems has two default config.

is it a bug? change config not use

config is

resilience4j:
  timelimiter:
    instances:
      default:
        timeoutDuration: 5s

image

dragontree101 commented 2 years ago

i change config to

resilience4j
  timelimiter:
    configs:
      default:
        timeoutDuration: 5s

it can set default timeout to 5s

alampada commented 2 years ago

i have the same question? it's bug or config error? @alampada @ctlove0523

@dragontree101 I believe that there is no bug. I have updated my repo with the right config and the circuit breaker and timelimiter work as I'd expect.

I believe this issue can be closed.