Search code examples
spring-bootspring-cloud

Spring cloud gateway response never arrives


I was trying out Spring Cloud Gateway (Finchley.M5). Then I built up this simple project based on Springboot 2 (2.0.0.M7):

  1. Eureka
  2. Spring Cloud Gateway
  3. A service (WebFlux @RestController)

When asking the service directly, the response arrives as expected:

enter image description here

But when I try to ask for the service through the Gateway, the service receives the request (I printed a message to the console) but the response never get back to the client:

enter image description here

The repo with the project is over here: https://github.com/julianobrasil/spring-gateway-test

[EDIT 1]: So you don't have to clone the above repo to see what is going on with the code, here it is:

1 - Gateway

@SpringBootApplication
@EnableDiscoveryClient
public class GatewayApplication {

  public static void main(String[] args) {
    SpringApplication.run(GatewayApplication.class, args);
  }

  @Bean
  public RouteLocator routes(RouteLocatorBuilder builder) {
    return builder.routes()
            .route(r -> r.path("/service/**")
                    .rewritePath("/service/(?<path>.*)", "/${path}")
                    .uri("lb://mySimpleService"))
            .build();
  }
}

2 - Service Controller

@RestController
public class MyController {

  @GetMapping("/test")
  Mono<String> getHello() {
    System.out.println("I received a connection request");
    return Mono.just("Hello, world!");
  }
}

[EDIT 2]: Someone on the Spring Cloud team has cloned my repo and tested it. And reported it worked just fine. Apparently, the test was made in a Linux system (I'm running it on a windows 10 machine).


Solution

  • I found out the real problem was a typical windows world problem: antivirus. Kaspersky was bloking the http response. To whom it may concern:

    enter image description here