Pardon me if the question is simple , but I don’t know what will happen in this general scenario : If due to some issue or failure / system failure (any kind of failure , etc) the browser crashes , what will happen to a websocket connection that was running ? Will it be closed or what will be its state ?
I am using netty websocket implementation. Now , specifically in netty websocket implementation , in the above scenario , what would happen ? (When I tried , I get this : if I close the browser manually , the connection is closed but if I kill the browser process , this does not happen). If the connection is not closed , how can I detect it / handle it while sending messages , otherwise while sending messages , a ClosedChannelException occurs when trying to send a message.
EDIT : Apart from checking for the above mentioned error , is there a way of knowing that the websocket connection has been closed when using the netty implementation ?
I think you’ll have to catch ClosedChannelException and handle that in the same way you would for a connection that was cleanly closed.
If your websocket sessions are expensive and you want to spot killed connections more quickly, you could periodically send a ping request to each client. Netty has a PingWebSocketFrame class which looks like it’d support this for you.