spring-cloud/spring-cloud-gateway

response timeout configuration through refresh via config-server

Open

#2.138 geöffnet am 3. Feb. 2021

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Java (3.204 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (4.284 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 21h) (18 gemergte PRs in 30 T)

Beschreibung

I want to disable the response-timeout entirely in gateway, which is possible by configuring spring.cloud.gateway.responseTimeout with NULL.

spring:
  cloud:
    gateway:
      httpclient:
        connectTimeout: 1000
        # defaults to NULL or explicit with responseTimeout: ~

I tested the YAML values 0, -1 and ~ (NULL) as responseTimeout and also removing the whole field to disable the timeout and then started the gateway:

  • 0 and -1 led to all proxy requests timeout immediatly
  • ~ and removing the field actually disables the responseTimeout

Now this is fine, it should maybe be mentioned in the documentation, maybe it's obvious ¯\_(ツ)_/¯

BUT

If you use configuration via spring cloud config and the /actuator/refresh endpoint to apply a new config it is impossible to disbale the responseTimeout.

Even worse, if you change the config in the config-server remote source to ~ or if you remove the field, the readTimeout silently stays at the previously configured value:

initial config on boot:

spring:
  cloud:
    gateway:
      httpclient:
        connectTimeout: 1000
        responseTimeout: 11000

=> downstream requests time out after 11 seconds

decrease responseTimout:

spring:
  cloud:
    gateway:
      httpclient:
        connectTimeout: 1000
        responseTimeout: 5000
curl -XPOST http://localhost:8943/actuator/refresh
# ["spring.cloud.gateway.httpclient.responseTimeout"]

=> downstream requests time out after 5 seconds

disable responseTimout:

spring:
  cloud:
    gateway:
      httpclient:
        connectTimeout: 1000
        responseTimeout: ~

or

spring:
  cloud:
    gateway:
      httpclient:
        connectTimeout: 1000
curl -XPOST http://localhost:8943/actuator/refresh
# ["spring.cloud.gateway.httpclient.responseTimeout"]

=> downstream requests time out after 5 seconds

So it looks like there is a different behaviour of the global gateway config when you reboot the revice or refresh it via config-client.

Contributor Guide