How can I close the WebSocket channel / connection from the server side correctly? If I use ctx.getChannel().close() , then onerror in Brwoser (Firefox 9) is raised:
Connection to ws: // localhost: 8080 / websocket was interrupted during page load
I also tried sending the CloseWebSocketFrame to the channelClosed method in the WebSocketServerHandler :
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { CloseWebSocketFrame close = new CloseWebSocketFrame(); ctx.getChannel().write(close); }
This raises a ClosedChannelException (perhaps related to this ?).
source share