zuul + ribbon set MaxAutoRetries : 3, but repeted 8 times why it happens?

30 Views Asked by At

My yml:

spring:
  application:
    name: test-gateway
  cloud:
    loadbalancer:
      retry:
        enabled: true

zuul:
  retryable: true
  set-content-length: true
  routes:
    test:
      path: /**
      serviceId: TEST
      stripPrefix: false
      sensitiveHeaders: Cookie,Set-Cookie

  ribbon:
    eager-load:
      enabled: true
  include-debug-header: true
  host:
    connect-timeout-millis: 1000
    socket-timeout-millis: 1000

TEST:
  ribbon:
    ReadTimeout: 1000
    ConnectTimeout: 1000
    retryableStatusCodes: 500, 503, 502, 408
    MaxAutoRetriesNextServer: 0
    OkToRetryOnAllOperations: true
    MaxAutoRetries: 3

when I called to api /foruser and it sleep 3000 milisec

    @GetMapping("/foruser")
    public String forUser() throws InterruptedException {

        log.info("Start to sleep count: {}", count);

        count = count + 1;

        sleep(3000);

        log.info("Finish sleep");

        return "every thing is ok";
    }

should retries just 3 times but repeated 8 times. Why? how can I set to retry just 3 times? where is any more config on ribbon?

1

There are 1 best solutions below

1
Dovile Barkauskaite On

Probem is with my spring boot version. Need zuul configuration. There I add github link were person write the zuul configuration which fixed my problem: https://gist.github.com/aldobongio/6a22f49863c7a777612f7887bbb8fd1d. Hope this will help for someone.