I want to try to set the Tomcat connectionUploadTimeout property within Spring Boot 2. I\'m getting some random non-reproducible java.net.SocketTimeoutException: null<
There's no need to guess which properties are supported as they're all listed in an appendix in the reference documentation. As you can hopefully see, there are no properties for configuring the connection upload timeout or for enabling the upload timeout on a Connector
. This means that those properties must be configured programatically.
You can configure the Connector
programmatically using a Tomcat-specific WebServerFactoryCustomizer
:
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatCustomizer() {
return (tomcat) -> tomcat.addConnectorCustomizers((connector) -> {
if (connector.getProtocolHandler() instanceof AbstractHttp11Protocol) {
AbstractHttp11Protocol<?> protocolHandler = (AbstractHttp11Protocol<?>) connector
.getProtocolHandler();
protocolHandler.setDisableUploadTimeout(false);
protocolHandler.setConnectionUploadTimeout(5000);
}
});
}