-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSocketClient not removing closed WebSocket Session's from managed beans #2655
Comments
Can replicate. Client Sessions are not being removed from WebSocketClient beans properly. |
Signed-off-by: Joakim Erdfelt <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
+ CDI requires a customized DecoratedObjectFactory, which is bound later in the lifecycle, which means we cannot rely on it being provided directly in the constructors, but rather have to look for it in the ServletContext. Signed-off-by: Joakim Erdfelt <[email protected]>
+ CDI requires a customized DecoratedObjectFactory, which is bound later in the lifecycle, which means we cannot rely on it being provided directly in the constructors, but rather have to look for it in the ServletContext. Signed-off-by: Joakim Erdfelt <[email protected]>
+ Correcting Native WebSocketConfiguration impact. + CDI requires a customized DecoratedObjectFactory, which is bound later in the lifecycle, which means we cannot rely on it being provided directly in the constructors, but rather have to look for it in the ServletContext. Signed-off-by: Joakim Erdfelt <[email protected]>
+ WebSocketClient all constructors now delegate down into one implementation + NativeWebSocketServletConfiguration is now managed properly + WebSocketServletFactory can find Executor as bean too Signed-off-by: Joakim Erdfelt <[email protected]>
…-session-removal Issue #2655 - Removing closed WebSocket Session's from WebSocketClient
Merged into jetty-9.4.x |
Websocket sessions (and their corresponding WebSocketClient threads) terminated due to idle timeout do not seem to be properly destroyed as of 9.4.14.v20181114. Implicitly calling close() on javax.websocket.Session inside Endpoint's onError/onClose or elsewhere does not help (though I assume this should not be necessary as Session.isOpen already reports false). Is it so that in case of embedded Jetty, as of 9.4.14.v20181114 in order to properly recycle Session and respective threads, it is still necessary to cast WebSocketContainer into Lifecycle and call stop as shown in embedded-jetty-websocket-examples? Also tested and confirming that casting WebSocketContainer to ClientContainer and calling getClient().stop() on it does the cleanup of threads as expected:
|
@joakime Is it possible to reopen this bug as per my report one month ago? |
@menulis can you try the latest code on branch |
Thanks for the reply, @sbordet. I tried 9.4.15.v2019021 and I no longer see the problem of With respect to the increasing number of threads with every newly established session, this is still the case if sessions are esablished by Do you have any estimates about when the next release will be available? |
jakartaee/websocket#212 - From a purely JSR356 point of view, there is no lifecycle for a JSR356 Client Container. It is supposed to live for the entirety of the JVM.
In regards to |
@menulis your usage of Regarding stopping the WebSocketContainer container = ContainerProvider.getWebSocketContainer();
container.connectToServer(...);
// When done with the container:
LifeCycle.stop(container); |
Thanks for clarifications, @sbordet and @joakime, they make a lot of sense and I have already adjusted the code accordingly. Stopping the container upon the shutdown of JVM is in fact a minor problem when compared to the memory leak due to |
@menulis Jetty 9.4.15 has landed in Maven Central, so it's now available to the public. Thanks for your feedback on this issue! |
Hi,
when a Websocket Session is closed, but instead of closing the WebSocketClient, a new websocket is opened, the annotated Websocket Handler is kept in the memory.
Please find the attached java example (put a breakpoint at line "System.out.println("Put a breakpoint here")". When it stops the client.toString() will show 100 open sessions, but they are already closed.
JettyClientCloseBug.zip
The text was updated successfully, but these errors were encountered: