Hello!
We have file descriptors leak when we use websocket client.
Our environment:
1. spring-boot 2.0.6
2. tomcat-embed 8.5.34
3. ubuntu 16.04
How to reproduce:
1. Connect to websocket server with using of WsWebSocketContainer (after
this step we will have WsSession and WsRemoteEndpointImplClient to send
messages)
2. Check the file descriptors usage (on my Ubuntu: lsof -p <java_pid> |
wc -l)
3. Reboot websocket server or stop it
4. Have result = -1 at WsFrameClientCompletionHandler.completed(...)
because of async channel was broken
5. At this method WsSession.close(...) and
WsSession.sendCloseMessage(...) will be called
6. At method WsSession.sendCloseMessage(...) will be called
wsRemoteEndpoint.sendMessageBlock(Constants.OPCODE_CLOSE, msg, true);
and sometimes it will be completed successful (without IOException
broken pipe) therefore async channel will not be closed and it's file
descriptor will not be released because of code block will not be reached:
}catch (IOException | WritePendingException e) {
...
wsRemoteEndpoint.close();
...
}
The problem is repeated often when we have many reconnect attemption
(when websocket server connection is constantly broken).
Thanks!