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

This commit is contained in:
weidong 2025-07-19 10:46:43 +08:00
parent 0acd7d31b8
commit bedb2e3ef5

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,future.cause().getMessage());
logger.info("{}:{} tcp connect failed. {}",host,port,future.cause().toString());
//重连交给后端线程执行
future.channel().eventLoop().schedule(() -> {
logger.info("{}:{} tcp client reconnect",host,port);
@ -96,7 +96,7 @@ public class TCPClient {
if (future.isSuccess()) {
logger.info("send to tcp:"+host+" succeed.");
} else {
logger.info("send to tcp: {} failed. {}",host,future.cause().getMessage());
logger.info("send to tcp: {} failed. {}",host,future.cause().toString());
if(listener!=null){
listener.onMessage("failed");
}