Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Is it necessary to close session in WebSocketConnectionListener.onWebSocketError ?

If you get an event on onClose() then you have transitioned from CONNECTED/OPEN to CLOSING in the WebSocket state.

That merely indicates that the close handshake has begun.
It could have been locally initiated, it could have been remote initiated.
It doesn't really matter which side started it, both sides are now involved in it.

onError will often (but not 100% of the time) result in a closed websocket.
Depending on when the onError occurs, you might not even have a onClose() event.

For example, when you have a failure during the initial websocket handshake during the attempt to OPEN the websocket state.
There's nothing to close if the error occurs then.

We try to call onClose for all cases where the state transitions from CONNECTED/OPEN to CLOSING.

There is no event for when the websocket state transitions from CLOSING to CLOSED.

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Thu, Oct 8, 2020 at 10:18 AM Alexander Farber <alexander.farber@xxxxxxxxx> wrote:
Good evening, the doc


says, that when onWebSocketClose is called, then the session is closed automatically.

But what about the other callback - the onWebSocketError?

As a developer, do I have to call mSession.close() there myself? Or is it closed already?

And another question please - is onWebSocketClose called, when I call mSession.close()?

Best regards
Alex
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top