2014-12-09 20:47 GMT+01:00 Mark Thomas <ma...@apache.org>:

> How would a message get into the socket buffer? The client needs a
> session to write a message and it won't get one until connectToServer
> returns.
>
> You misunderstood it, the client opens the connection, and the server
sends back a message during onOpen, which may get in the socket buffer of
the client and call onMessage right away. That's a really rare scenario and
I'm not sure it is as intended since it is inconsistent (but fixing it may
not be worth it).

The stack in this case looks like this:
    at
org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:393)
    at
org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:496)
    at
org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:289)
    at
org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130)
    at
org.apache.tomcat.websocket.WsFrameClient.processSocketRead(WsFrameClient.java:72)
    at
org.apache.tomcat.websocket.WsFrameClient.startInputProcessing(WsFrameClient.java:52)
    at
org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:381)
    at
org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:198)

In nearly all cases, onMessage is called instead from a completion handler
on another thread rather than inline.

Rémy

Reply via email to