Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load balance per route read timeout in spring-cloud-gateway-server-mvc #3378

Open
jluiz20 opened this issue Apr 30, 2024 · 1 comment
Open

Comments

@jluiz20
Copy link

jluiz20 commented Apr 30, 2024

Describe the bug
I am migrating our current gateway from zuul to Spring Cloud Gateway Server MVC and I am not sure if it is a bug or just me that is missing something but I am trying to add a timeout for a specific service and I am not able to make it work.

when I define a global timeout, using the following configuration

spring:
  cloud:
    gateway:
      mvc:
        http-client:
          read-timeout: 3s

I get a java.net.SocketTimeoutException but when I define it in the metadata of the simple instance, like below

spring:
  cloud:
    discovery:
      client:
        simple:
          instances:
           my-service:
              - uri: http://localhost:9169
                metadata:
                  read-timeout: 1s

it does not work. I even tried to use the response-timeout from here

but it seems that is only for the reactive version.

Is there any other way I could set a per-route route read-timeout?

PS: I am setting up a router, like in the samples https://github.com/spencergibb/spring-cloud-gateway-mvc-sample/blob/396005238cec0ad9b66ee01ea7e3006aa6aed5a6/src/main/java/com/example/gatewaymvcsample/Route01FirstRoute.java#L16-L16

    @Bean
    public RouterFunction<ServerResponse> myServiceRouter() {
        return route()
                .route(path("/my-service/**"), http())
                .filter(lb("my-service"))
                //other filters
                .build();
    }

I am currently using spring-cloud-gateway-server-mvc:4.1.2

Thank you for the project and in advance for any help.

@spencergibb
Copy link
Member

Metadata read timeout is not built for server webmvc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants