异常日志调整

This commit is contained in:
aoshiguchen
2025-11-19 17:05:34 +08:00
parent f124557686
commit 9cbcf4de2e
7 changed files with 39 additions and 7 deletions
@@ -13,6 +13,8 @@ import io.netty.handler.timeout.IdleStateEvent;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.Solon;
import java.net.SocketException;
/**
* 处理与服务端之间的数据传输
* @author: aoshiguchen
@@ -58,8 +60,11 @@ public class CmdChannelHandler extends SimpleChannelInboundHandler<ProxyMessage>
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof SocketException && cause.getMessage().contains("Connection reset")) {
ctx.channel().close();
return;
}
log.error("[CMD Channel]Client CmdChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
ctx.close();
}
@Override
@@ -10,6 +10,8 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOption;
import io.netty.channel.SimpleChannelInboundHandler;
import java.net.SocketException;
/**
* 处理与被代理客户端的数据传输
* @author: aoshiguchen
@@ -76,6 +78,10 @@ public class RealServerChannelHandler extends SimpleChannelInboundHandler<ByteBu
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof SocketException && cause.getMessage().contains("Connection reset")) {
ctx.channel().close();
return;
}
log.error("Client ProxyChannel Error", cause);
}
}
@@ -12,6 +12,8 @@ import org.dromara.neutrinoproxy.core.ProxyMessage;
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
import org.noear.solon.Solon;
import java.net.SocketException;
/**
* 处理与服务端之间的数据传输
* @author: aoshiguchen
@@ -53,8 +55,11 @@ public class TcpProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof SocketException && cause.getMessage().contains("Connection reset")) {
ctx.channel().close();
return;
}
log.error("[TCP Proxy Channel]Client ProxyChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
ctx.close();
}
@Override
@@ -12,6 +12,8 @@ import org.dromara.neutrinoproxy.core.ProxyMessage;
import org.dromara.neutrinoproxy.core.dispatcher.Dispatcher;
import org.noear.solon.Solon;
import java.net.SocketException;
/**
* 处理与服务端之间的数据传输
* @author: aoshiguchen
@@ -53,8 +55,11 @@ public class UdpProxyChannelHandler extends SimpleChannelInboundHandler<ProxyMes
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof SocketException && cause.getMessage().contains("Connection reset")) {
ctx.channel().close();
return;
}
log.error("[UDP Proxy Channel]Client ProxyChannel Error channelId:{}", ctx.channel().id().asLongText(), cause);
ctx.close();
}
@Override
@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.noear.solon.Solon;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.util.Date;
/**
@@ -108,6 +109,10 @@ public class ProxyTunnelChannelHandler extends SimpleChannelInboundHandler<Proxy
// if (ctx.channel().isActive()) {
// ctx.channel().close();
// }
if (cause instanceof SocketException && cause.getMessage().contains("Connection reset")) {
ctx.channel().close();
return;
}
log.error("[Tunnel Channel] error", cause);
}
@@ -16,6 +16,7 @@ import org.dromara.neutrinoproxy.server.util.ProxyUtil;
import org.noear.solon.Solon;
import java.net.InetSocketAddress;
import java.net.SocketException;
/**
*
@@ -27,8 +28,10 @@ public class TcpVisitorChannelHandler extends SimpleChannelInboundHandler<ByteBu
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// 当出现异常就关闭连接
ctx.close();
if (cause instanceof SocketException && cause.getMessage().contains("Connection reset")) {
ctx.channel().close();
return;
}
log.error("VisitorChannel error", cause);
}
@@ -17,6 +17,7 @@ import org.dromara.neutrinoproxy.server.util.ProxyUtil;
import org.noear.solon.Solon;
import java.net.InetSocketAddress;
import java.net.SocketException;
/**
* @author: aoshiguchen
@@ -116,8 +117,10 @@ public class UdpVisitorChannelHandler extends SimpleChannelInboundHandler<Datagr
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
// 当出现异常就关闭连接
ctx.close();
if (cause instanceof SocketException && cause.getMessage().contains("Connection reset")) {
ctx.channel().close();
return;
}
log.error("[UDP Visitor Channel]VisitorChannel error", cause);
}