Home > Mobile >  Tomcat default value for socket.soKeepAlive
Tomcat default value for socket.soKeepAlive

Time:10-20

I am trying to debug an issue related to keep-alives/connection resets and found that tomcat documentation says:

socket.soKeepAlive:

(bool)Boolean value for the socket's keep alive setting (SO_KEEPALIVE). JVM default used > if not set.

This is not set by the application I am debugging. Is there a way to figure out the default the jvm is using? (For instance by inspecting a system property?)

I cannot test out the behavior by inspecting the actual keep alive behavior since I don't have access to the VM.

CodePudding user response:

Answering on my own based on more research and experimentation.

Default value of socket.soKeepAlive: From the JVM docs for SocketOptions.SO_KEEPALIVE:

The initial value of this socket option is FALSE. The socket option may be enabled or disabled at any time.

Also to note:

When the SO_KEEPALIVE option is enabled the operating system may use a keep-alive mechanism to periodically probe the other end of a connection

From what I understood, this would mean tomcat would not probe clients to check if an established connection is active by default

Default Value of keepAliveTimeout: The default value is to use the value that has been set for the connectionTimeout attribute

In my case this was not being reflected. connectionTimeout was set to 10 seconds, but still tomcat responses had keep alive headers set to only 5 seconds.

However, I found that the application authors also set an attribute called socket.soTimeout to 5 seconds which tomcat describes as:

This is equivalent to standard attribute connectionTimeout.

I found that when both conncetionTimeout and socket.soTimeout are set, socket.soTimeout takes precedence since changing the socket.soTimeout value caused the values returned by keep alive headers to change accordingly.

  • Related