I met a problem when testing the performance of spring reactive projects with Apache Bench.
ab http://localhost:8080/hi
The result shows timeout.
But it's OK for curl http://localhost:8080/hi
My project uses Spring boot version is 2.0.0.M6. I will paste some of the code.
pom.xml is
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-reactor-netty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
MyRouter.java
@Component
public class MyRouter {
private static final Logger logger = LoggerFactory.getLogger(MyRouter.class);
@Bean
RouterFunction<ServerResponse> router(PersonHandler personHandler) {
return route(GET("/hi"), request -> ok().body(BodyInserters.fromObject("hello")));
}
}