jetty.project/jetty-websocket/websocket-common/websocket-states.txt

108 lines
3.1 KiB
Plaintext
Raw Normal View History

2017-04-21 19:21:07 -04:00
Documenting the States of a WebSocket Session.
2017-04-21 12:00:30 -04:00
2017-04-21 19:21:07 -04:00
NEW: (Internal)
2017-04-21 12:00:30 -04:00
A new WebSocket session.
It has had no connection attempted yet.
2017-04-21 19:21:07 -04:00
CONNECTING: (RFC6455) // synonyms: HANDSHAKING
2017-04-21 12:00:30 -04:00
The connection is being attempted, along with the Upgrade handshake.
2017-04-21 19:21:07 -04:00
CONNECTED: (Internal) // synonyms: HANDSHAKED, HANDSHAKEN, OPENING
2017-04-21 12:00:30 -04:00
The connection is established.
The User WebSocket Endpoint has not been notified yet.
2017-04-21 19:21:07 -04:00
OPEN: (RFC6455) // synonyms: OPENED
2017-04-21 12:00:30 -04:00
2017-04-21 19:21:07 -04:00
User WebSocket Endpoint is now Opened (the onOpen method has been called, no close by onOpen)
2017-04-21 12:00:30 -04:00
2017-04-21 19:21:07 -04:00
CLOSING: (RFC6455)
2017-04-21 12:00:30 -04:00
The close handshake has begun.
Either the local initiated the close, waiting for the remote to reply.
Or the remote initiated the close, and the local hasn't replied yet.
This can be considered a logical half-closed state.
2017-04-21 19:21:07 -04:00
+ (sub state) CLOSE_FRAME_SENT (bool)
CLOSED: (RFC6455)
2017-04-21 12:00:30 -04:00
The connection and session is closed.
This means either the close handshake completed, or the connection was
disconnected for other reasons.
----
Normal Client Initiated Close State Transition
2017-04-21 19:21:07 -04:00
Client: State: NEW
Client: WSEndpoint created
Client: WSSession created
2017-04-21 12:00:30 -04:00
Http GET w/Upgrade initiated
2017-04-21 19:21:07 -04:00
Client: State: CONNECTING
2017-04-21 12:00:30 -04:00
Upgrade Handshake negotiated (HTTP 101 response)
2017-04-21 19:21:07 -04:00
Client: State: CONNECTED
Client: WSEndpoint.onOpen() called
Client: State: OPEN
Client: WSEndpoint.onMessage() - received msg
Client: WSSession.close(local close details)
Client: State: CLOSING
Client: Send CLOSE Frame to remote
Remote: Received CLOSE Frame from client
Remote: Sends CLOSE Frame reply (remote close details)
Client: WSEndpoint.onClose(remote close details)
Client: State: CLOSED
Client: TCP Connection disconnect completely
2017-04-21 12:00:30 -04:00
----
Normal Remote Initiated Close State Transition
2017-04-21 19:21:07 -04:00
Client: State: NEW
Client: WSEndpoint created
Client: WSSession created
2017-04-21 12:00:30 -04:00
Http GET w/Upgrade initiated
2017-04-21 19:21:07 -04:00
Client: State: CONNECTING
2017-04-21 12:00:30 -04:00
Upgrade Handshake negotiated (HTTP 101 response)
2017-04-21 19:21:07 -04:00
Client: State: CONNECTED
Client: WSEndpoint.onOpen() called
Client: State: OPEN
Client: WSEndpoint.onMessage() - received msg
Remote: Sends CLOSE Frame (remote close details)
Client: Received CLOSE Frame from remote
Client: State: CLOSING
Client: WSEndpoint.onClose(remote close details)
Client: after onClose()
if can transition to CLOSED
Client: Sends CLOSE Frame
Client: TCP Connection disconnect completely
---
Overlapping Close State (Remote first) Transition
Client: WSEndpoint created
Client: WSSession created
Http GET w/Upgrade initiated
Client: State: CONNECTING
Upgrade Handshake negotiated (HTTP 101 response)
Client: State: CONNECTED
Client: WSEndpoint.onOpen() called
Client: State: OPEN
Client: WSEndpoint.onMessage() - received msg
Remote[t1]: Sends CLOSE Frame (remote close details)
Client[t2]: WSSession.close(local close details)
Client[t2]: State: CLOSING
Client[t1]: Received CLOSE Frame from remote
Client[t1]: Cannot transition to State: CLOSING (no-op)
Client[t1]: WSEndpoint.onClose(remote close details)
Client[t1]: after onClose()
if can transition to CLOSED
Client: Sends CLOSE Frame
Client: TCP Connection disconnect completely
2017-04-21 12:00:30 -04:00