Setting tomcat connectionUploadTimeout in Spring Boot

后端 未结 1 2006
眼角桃花
眼角桃花 2021-01-16 16:20

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<

相关标签:
1条回答
  • 2021-01-16 16:57

    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);
            }
        });
    }
    
    0 讨论(0)
提交回复
热议问题