Search code examples
javatomcatembedded-tomcat-7

Modify SO_TIMEOUT (read timeout) for embedded tomcat


How can I modify the read timeout for embedded tomcat?
From Apache Tomcat Configuration Reference:

socket.soTimeout
Value in milliseconds for the sockets read timeout (SO_TIMEOUT). Default value is 5000 milliseconds.

I've tried the following

    httpConnector.setAttribute("channelNioSocket.soTimeout", 1);
    httpConnector.setAttribute("soTimeout", 1);
    httpConnector.setAttribute("SO_TIMEOUT", 1);

I expected to get SocketTimeoutException as I changed the value to 1 millisecond, but didn't, so I assume it's not working.


Solution

  • Found it!

    org.apache.catalina.connector.Connector#setProperty
    

    For example:

    httpConnector.setProperty("soTimeout", "50000");