Exceptions while trying to disconnect Websocket Clients

284 views
Skip to first unread message

Chriz

unread,
Jun 1, 2012, 5:54:32 AM6/1/12
to cometd-users
Hi again,

another Question, after we ran a benchmark test (where all Clients are
websocket clients) we tried to disconnect all Clients afterwards. (I
have to say we wrote our very own Benchmark Test) With Long-Polling
Transportmode this works without problems. If the client uses
Websockets, we'll get exceptions:

21608 [qtp12115735-16] INFO org.cometd.client.BayeuxClient.2208288 -
Messages failed [{id=52, connectionType=websocket, channel=/meta/
connect, clientId=1221fkyt8hx9zyri1xt2f068c1s47}]
java.io.EOFException: Connection closed 1000 Disconnect

Seems like the actual socket is closed, but when we try like
client.isConnected(), it returns true.... Any suggestions?

Chriz

Simone Bordet

unread,
Jun 1, 2012, 6:05:07 AM6/1/12
to cometd...@googlegroups.com
Hi,
Strange, I never saw this problem with the CometD load test tools.

How do you disconnect the clients ?

Do you have a debug log that shows the problem ?

Simon
--
http://cometd.org
http://intalio.com
http://bordet.blogspot.com
----
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz

Christian

unread,
Jun 1, 2012, 7:25:27 AM6/1/12
to cometd...@googlegroups.com
Hi.


How do you disconnect the clients ?

  public void destroy() throws Exception {
        if(client.isConnected()){
            try{
                client.getChannel(configurationHolder.getChannel()).unsubscribe();
                client.disconnect();
            }catch(Exception e){}

        }
    }

Do you have a debug log that shows the problem ?

Here is a complete stacktrace:
2012-06-01 13:24:11.382  qtp26872956-14    INFO  org.cometd.client.BayeuxClient       992 :onFailure                      - Messages failed [{id=10151, connectionType=websocket, channel=/meta/connect, clientId=26jlii3j9sg5exp15kjx6f8qwcqt}]

java.io.EOFException: Connection closed 1000 Disconnect
    at org.cometd.websocket.client.WebSocketTransport$CometDWebSocket.onClose(WebSocketTransport.java:506) [cometd-websocket-jetty-2.4.3.jar:na]
    at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455.closeOut(WebSocketConnectionRFC6455.java:368) [jetty-websocket-8.1.4.v20120524.jar:8.1.4.v20120524]
    at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameConnection.close(WebSocketConnectionRFC6455.java:499) [jetty-websocket-8.1.4.v20120524.jar:8.1.4.v20120524]
    at org.cometd.websocket.client.WebSocketTransport.disconnect(WebSocketTransport.java:183) [cometd-websocket-jetty-2.4.3.jar:na]
    at org.cometd.websocket.client.WebSocketTransport.onMessages(WebSocketTransport.java:485) [cometd-websocket-jetty-2.4.3.jar:na]
    at org.cometd.websocket.client.WebSocketTransport$CometDWebSocket.onMessage(WebSocketTransport.java:515) [cometd-websocket-jetty-2.4.3.jar:na]
    at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameHandler.onFrame(WebSocketConnectionRFC6455.java:845) [jetty-websocket-8.1.4.v20120524.jar:8.1.4.v20120524]
    at org.eclipse.jetty.websocket.WebSocketParserRFC6455.parseNext(WebSocketParserRFC6455.java:359) [jetty-websocket-8.1.4.v20120524.jar:8.1.4.v20120524]
    at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455.handle(WebSocketConnectionRFC6455.java:235) [jetty-websocket-8.1.4.v20120524.jar:8.1.4.v20120524]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:620) [jetty-io-8.1.4.v20120524.jar:8.1.4.v20120524]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) [jetty-io-8.1.4.v20120524.jar:8.1.4.v20120524]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) [jetty-util-8.1.4.v20120524.jar:8.1.4.v20120524]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) [jetty-util-8.1.4.v20120524.jar:8.1.4.v20120524]
    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_26]
2012-06-01 13:24:11.399  qtp26872956-14    DEBUG o.c.client.transport.ClientTransport 70  :debug                          - Deregistering null for message {id=9979, connectionType=websocket, channel=/meta/connect, clientId=25ed747mcjd0sis6dsks3yeobwi}
2012-06-01 13:24:11.399  qtp26872956-14    DEBUG org.cometd.client.BayeuxClient       858 :debug                          - State not updateable: DISCONNECTED -> UNCONNECTED

Regards
Christian

2012/6/1 Simone Bordet <sbo...@intalio.com>

--
You received this message because you are subscribed to the Google Groups "cometd-users" group.
To post to this group, send email to cometd...@googlegroups.com
To unsubscribe from this group, send email to cometd-users...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cometd-users

Visit the CometD website at http://www.cometd.org

Chriz

unread,
Jun 3, 2012, 10:19:14 AM6/3/12
to cometd-users
Hi,
Any News to my issue? Simone die you find Anything relating to my
problem?

Thx
Christian

On 1 Jun., 13:25, Christian <chrizmas...@googlemail.com> wrote:
> Hi.
>
> How do you disconnect the clients ?
>
>   public void destroy() throws Exception {
>         if(client.isConnected()){
>             try{
>
> client.getChannel(configurationHolder.getChannel()).unsubscribe();
>                 client.disconnect();
>             }catch(Exception e){}
>         }
>     }
>
> Do you have a debug log that shows the problem ?
>
> *Here is a complete stacktrace:*
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint. java:46)
> [jetty-io-8.1.4.v20120524.jar:8.1.4.v20120524]
>     at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java :603)
> [jetty-util-8.1.4.v20120524.jar:8.1.4.v20120524]
>     at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java: 538)
> [jetty-util-8.1.4.v20120524.jar:8.1.4.v20120524]
>     at java.lang.Thread.run(Thread.java:662) [na:1.6.0_26]
> 2012-06-01 13:24:11.399  qtp26872956-14    DEBUG
> o.c.client.transport.ClientTransport 70  :debug                          -
> Deregistering null for message {id=9979, connectionType=websocket,
> channel=/meta/connect, clientId=25ed747mcjd0sis6dsks3yeobwi}
> 2012-06-01 13:24:11.399  qtp26872956-14    DEBUG
> org.cometd.client.BayeuxClient       858 :debug                          -
> State not updateable: DISCONNECTED -> UNCONNECTED
>
> Regards
> Christian
>
> 2012/6/1 Simone Bordet <sbor...@intalio.com>
>
>
>
>
>
>
>
> > Hi,

Simone Bordet

unread,
Jun 3, 2012, 10:34:01 AM6/3/12
to cometd...@googlegroups.com
Hi,

On Sun, Jun 3, 2012 at 4:19 PM, Chriz <chriz...@googlemail.com> wrote:
> Hi,
> Any News to my issue? Simone die you find Anything relating to my
> problem?

The "problem" is an inherent race condition between an outstanding
/meta/connect and a disconnect.
When the client disconnects, the server should also return the
/meta/connect (and eventually queued messages), but this happens in
another thread.
The client sees the disconnect response and closes the connection,
killing also the outstanding /meta/connect, which is causes with the
exception you reported.

Now, this "problem" is not really a problem, and you can safely ignore it.

We have a number of tricks that we use to avoid this condition as much
as we can, but it's intrinsic in the Bayeux protol.

Do you have also a debug of the server-side ? That will probably help
in adding one more trick to avoid this exception to happen.

>>   public void destroy() throws Exception {
>>         if(client.isConnected()){
>>             try{
>>
>> client.getChannel(configurationHolder.getChannel()).unsubscribe();
>>                 client.disconnect();
>>             }catch(Exception e){}
>>         }
>>     }

Calling unsubscribe() and then disconnect() is not recommended
(unsubscribe is asynchronous, and may be sent after the disconnect).
Just disconnect: the server will take care of unsubscribing on the
server-side, and subscriptions are cleared on client-side anyway.

If you remove the unsubscribe() call, do you still see the problem ?
Reply all
Reply to author
Forward
0 new messages