Do I configure properties like the connectionTimeout in the application.properties file or is the somewhere else to do it? I can't figure this out from Google.
Tomcat properties list
I found this Spring-Boot example, but it does not include a connectionTimeout property and when I set server.tomcat.connectionTimeout=60000
in my application.properties file I get an error.
As of Spring Boot 1.4 you can use the property server.connection-timeout
. See Spring Boot's common application properties.
Provide a customized EmbeddedServletContainerFactory
bean:
@Bean
public EmbeddedServletContainerFactory servletContainerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.addConnectorCustomizers(connector ->
((AbstractProtocol) connector.getProtocolHandler()).setConnectionTimeout(10000));
// configure some more properties
return factory;
}
If you are not using Java 8 or don't want to use Lambda Expressions, add the TomcatConnectorCustomizer
like this:
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
((AbstractProtocol) connector.getProtocolHandler()).setConnectionTimeout(10000);
}
});
The setConnectionTimeout()
method expects the timeout in milliseconds (see connectionTimeout
in Apache Tomcat 8 Configuration Reference).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With