mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] Улучшение обработки ошибок websocket
This commit is contained in:
parent
584e07328c
commit
92df57e491
1 changed files with 22 additions and 2 deletions
|
@ -56,9 +56,29 @@ public void channelActive(ChannelHandlerContext ctx) {
|
|||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) {
|
||||
// ping and pong frames already handled
|
||||
if (hooks.hook(ctx, frame)) return;
|
||||
try {
|
||||
if (hooks.hook(ctx, frame)) return;
|
||||
} catch (Throwable ex)
|
||||
{
|
||||
LogHelper.error(ex);
|
||||
}
|
||||
if (frame instanceof TextWebSocketFrame) {
|
||||
service.process(ctx, (TextWebSocketFrame) frame, client, context.ip);
|
||||
try {
|
||||
service.process(ctx, (TextWebSocketFrame) frame, client, context.ip);
|
||||
} catch (Throwable ex) {
|
||||
if(LogHelper.isDebugEnabled()) {
|
||||
LogHelper.warning("Client %s send invalid request. Connection force closed.", context.ip == null ? IOHelper.getIP(ctx.channel().remoteAddress()) : context.ip);
|
||||
if(LogHelper.isDevEnabled())
|
||||
{
|
||||
LogHelper.dev("Client message: %s", ((TextWebSocketFrame) frame).text());
|
||||
}
|
||||
if(LogHelper.isStacktraceEnabled())
|
||||
{
|
||||
LogHelper.error(ex);
|
||||
}
|
||||
}
|
||||
ctx.channel().close();
|
||||
}
|
||||
} else if ((frame instanceof PingWebSocketFrame)) {
|
||||
frame.content().retain();
|
||||
ctx.channel().writeAndFlush(new PongWebSocketFrame(frame.content()));
|
||||
|
|
Loading…
Reference in a new issue