https://bz.apache.org/bugzilla/show_bug.cgi?id=62539
Bug ID: 62539
Summary: WsSession cannot be GC while send close message
timeout
Product: Tomcat 8
Version: 8.5.31
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: WebSocket
Assignee: dev@tomcat.apache.org
Reporter: zx...@126.com
Target Milestone:
In my application, after few days, the oldGen memory will reach to 99%。
I dump the memory, the WsSession hold most memory, total 400+, but current
webSocket connections is only 30+, the most wsSession state is OUTPUT_CLOSED
I debug in local,
while i call WsSession.close(), if failed to send close message(timeout), the
session's state is OUTPUT_CLOSED, and cannot be GC ,then use netstat -ant, the
tcp connect is already closed ant not exist
In WsSession.sendCloseMessage's exception catch has the notes blow:
```
// Failed to send close message. Close the socket and let the caller
// deal with the Exception
// Failure to send a close message is not unexpected in the case of
// an abnormal closure (usually triggered by a failure to read/write
// from/to the client. In this case do not trigger the endpoint's
// error handling
```
Meaning that let caller deal the exception, but WsSession's state is
OUTPUT_CLOSED, In WsSession.doClose method, if state is OUTPUT_CLOSED will
no longer trigger sendCloseMessage and fireEndpointOnClose, this cause the
session cannot be GC
The exception is below:
```
2018-07-14 17:43:26.154 DEBUG 7170 --- [-collect-pool-5]
org.apache.tomcat.websocket.WsSession: Closing WebSocket session [{1}]
2018-07-14 17:43:46.170 DEBUG 7170 --- [-collect-pool-5]
org.apache.tomcat.websocket.WsSession: Failed to send close message for
session [0] to remote endpoint
java.net.SocketTimeoutException: The current message was not fully sent within
the specified timeout
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:299)
at
org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendMessageBlock(WsRemoteEndpointImplBase.java:258)
at
org.apache.tomcat.websocket.WsSession.sendCloseMessage(WsSession.java:592)
at org.apache.tomcat.websocket.WsSession.doClose(WsSession.java:480)
at org.apache.tomcat.websocket.WsSession.close(WsSession.java:445)
at
org.springframework.web.socket.adapter.standard.StandardWebSocketSession.closeInternal(StandardWebSocketSession.java:223)
at
org.springframework.web.socket.adapter.AbstractWebSocketSession.close(AbstractWebSocketSession.java:137)
```
--
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org