1、增加TCP连接过程打印,以便查看连接失败原因

This commit is contained in:
weidong 2025-07-19 10:01:50 +08:00
parent 1996ef79d4
commit 063716d539

View File

@ -62,7 +62,7 @@ public class TCPClient {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (!future.isSuccess()) {
logger.info("{}:{} tcp connect failed",host,port);
logger.info("{}:{} tcp connect failed. {}",host,port,future.cause().getMessage());
//重连交给后端线程执行
future.channel().eventLoop().schedule(() -> {
logger.info("{}:{} tcp client reconnect",host,port);
@ -92,7 +92,7 @@ public class TCPClient {
if (future.isSuccess()) {
logger.info("send to tcp:"+host+" succeed.");
} else {
logger.info("send to tcp:"+host+" failed.");
logger.info("send to tcp: {} failed. {}",host,future.cause().getMessage());
if(listener!=null){
listener.onMessage("failed");
}