I've deployed my high traffic SpringBoot Application on Wildfly 10. The server architecture for this application is nginx (Angular Application) -> (reverse proxy) -> wildfly server. Since we get high traffic during the hours, the 8080 port (wildfly application port) stays at CLOSE_WAIT because nginx closes the connection after certain period of time.
I'm looking to configure the Spring Boot Application to close the connection if the request time is lets say > than 5 seconds.
Example:
@GetMapping("test1")
public ResponseEntity test1(){
return ResponseEntity.ok("TESTED!");
}
@GetMapping("test2")
public ResponseEntity test2() throws InterruptedException{
Thread.sleep(300000);
return ResponseEntity.ok("TESTED!");
}
For test2 Get HTTP method is there a way to configure spring boot application / Wildfly / centos to set connection timeout for incoming request?
You can try server.connection-timeout=300000
in your application.properties.
From the official documentation:
server.connection-timeout= # Time in milliseconds that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1 to indicate no (ie infinite) timeout.
Or you can try to use the @Transactional
annotation and set an argument to it as that:
@Transactional(timeout = 300000)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.