Hi Joakim,

Looks like the problem is that we are adding the session as a managed bean
at
https://github.com/eclipse/jetty.project/blob/ac24196b0d341534793308d585161381d5bca4ac/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java#L609,
but it is not getting removed. In case of WebsocketAdapter, onSessionOpened()
and onSessionClosed() are getting called, so it is getting cleaned up. In
case of jsr library, these are not getting called.

I'm wondering if we can just remove addManaged() call in upgrade()? Or
should we call remove() for jsr bean also? I can give a try fixing this if
you can give the guidance.

Regards,
amit


On Thu, Jan 7, 2016 at 5:34 PM, Amit Dev <[email protected]> wrote:

> I could also reproduce the problem (on Jetty 9.3.6.v20151106) using the
> demo code at
> https://github.com/jetty-project/embedded-websocket-echo-examples. If I
> use code at demo/jsr, the issue is there (EchoSocket objects linger). But
> if I use demo/adapter, things are working fine.
>
> Regards,
> amit
>
> On Thu, Jan 7, 2016 at 12:37 PM, Amit Dev <[email protected]> wrote:
>
>> Hi Joakim,
>>
>> Thanks for your reply. I'm using Jetty 9.3.6.v20151106. Did you refer to
>> issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=481986? The same
>> thing is not working for me. The JsrSession and WSEndpoint objects keep on
>> increasing if I open and close websocket sessions and never getting gc'd. I
>> tried with default settings of ServerContainer and still no change.
>>
>> Regards,
>> amit
>>
>> On Thu, Jan 7, 2016 at 12:15 AM, Joakim Erdfelt <[email protected]>
>> wrote:
>>
>>> This was a reported bug and fixed in the latest version of Jetty.
>>> Be sure you are using the latest version of Jetty, use  9.3.6.v20151106.
>>>
>>> Also of note, there's Session close (the websocket layer), and
>>> connection close (the endpoint layer).
>>> If you harsh close the connection layer, without going through a proper
>>> Session close handshake, then the idle timeout has to kick in to close the
>>> Connection and then Session.
>>>
>>>
>>> Joakim Erdfelt / [email protected]
>>>
>>> On Wed, Jan 6, 2016 at 10:55 AM, Amit Dev <[email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm using websockets with embedded jetty and somehow the websocket
>>>> related objects are not cleaned up even after closing the connection. I'm
>>>> using it as follows:
>>>>
>>>> @ServerEndpoint(value="/websocket/")
>>>> public class WebSocketEndpoint {
>>>>  @OnOpen
>>>>  void foo() {}
>>>>
>>>>  @OnClose
>>>>  void bar() {}
>>>> }
>>>>
>>>> etc. Everything is working fine, except that the endpoint objects are
>>>> not getting gc'd. Looks like it is referred by ApplicationShutdownHooks or
>>>> something. Following is a partial snapshot of referred objects:
>>>>
>>>> this     - value: WebSocketEndpoint #1
>>>>  <- websocket     - class:
>>>> org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver,
>>>> value: com.oracle.ofsc.chat.endpoints.WebSocketEndpoint #1
>>>>   <- incomingHandler     - class:
>>>> org.eclipse.jetty.websocket.jsr356.JsrSession, value:
>>>> org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver #1
>>>>    <- _bean     - class:
>>>> org.eclipse.jetty.util.component.ContainerLifeCycle$Bean, value:
>>>> org.eclipse.jetty.websocket.jsr356.JsrSession #1
>>>>     <- [2]     - class: java.lang.Object[], value:
>>>> org.eclipse.jetty.util.component.ContainerLifeCycle$Bean #82
>>>>      <- array     - class: java.util.concurrent.CopyOnWriteArrayList,
>>>> value: java.lang.Object[] #2869
>>>>       <- _beans     - class:
>>>> org.eclipse.jetty.websocket.server.WebSocketServerFactory, value:
>>>> java.util.concurrent.CopyOnWriteArrayList #70
>>>>        <- webSocketServerFactory     - class:
>>>> org.eclipse.jetty.websocket.jsr356.server.ServerContainer, value:
>>>> org.eclipse.jetty.websocket.server.WebSocketServerFactory #1
>>>>         <- [0]     - class: java.lang.Object[], value:
>>>> org.eclipse.jetty.websocket.jsr356.server.ServerContainer #1
>>>>          <- array     - class:
>>>> java.util.concurrent.CopyOnWriteArrayList, value: java.lang.Object[] #2001
>>>>           <- _lifeCycles     - class:
>>>> org.eclipse.jetty.util.thread.ShutdownThread, value:
>>>> java.util.concurrent.CopyOnWriteArrayList #55
>>>>            <- [36]     - class: java.lang.Object[], value:
>>>> org.eclipse.jetty.util.thread.ShutdownThread #1
>>>>             <- table     - class: java.util.IdentityHashMap, value:
>>>> java.lang.Object[] #1084
>>>>              <- hooks (sticky class)     - class:
>>>> java.lang.ApplicationShutdownHooks, value: java.util.IdentityHashMap #1
>>>>
>>>> Any help is greatly appreciated. I'm trying to debug further.
>>>>
>>>> Thanks,
>>>> amit
>>>>
>>>> _______________________________________________
>>>> jetty-users mailing list
>>>> [email protected]
>>>> To change your delivery options, retrieve your password, or unsubscribe
>>>> from this list, visit
>>>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>>>>
>>>
>>>
>>> _______________________________________________
>>> jetty-users mailing list
>>> [email protected]
>>> To change your delivery options, retrieve your password, or unsubscribe
>>> from this list, visit
>>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>>>
>>
>>
>
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to