We are encountering a persistent socket state issue in WildFly 26/31 involving the Undertow web server. Specifically, after an HTTP client closes its connection, the corresponding server-side socket remains in the CLOSE_WAIT state for approximately 2 minutes. This behavior is reproducible under normal load and occurs even when the client has properly terminated the connection.
From our investigation, it appears that Undertow does not immediately close its end of the socket, which leads to a buildup of sockets in CLOSE_WAIT. This can cause resource exhaustion under high traffic conditions. We have verified that the client is not keeping the connection open and that the server receives the TCP FIN signal, yet the socket remains open on the server side until the timeout expires.
We attempted to mitigate this by tuning Undertow settings, such as disabling tcp-keep-alive, but the CLOSE_WAIT duration remains close to 2 minutes. Additionally, we found that WildFly does not expose low-level socket options like SO_LINGER in the Undertow subsystem configuration, which limits our ability to force immediate socket closure.
We would like to understand:
Whether this behavior is expected in Undertow’s default configuration.
If there are any supported configuration options to reduce the CLOSE_WAIT linger time.
Whether this can be addressed in future releases or via custom extensions.
Please advise on best practices or configuration changes that can help resolve or mitigate this issue.
[ser ~]# date;netstat -na | grep 8080