fix 服务端添加心跳监听

This commit is contained in:
wujiawei 2024-01-03 14:41:48 +08:00
parent 4f8d1d206c
commit cbd0d7c954
4 changed files with 44 additions and 44 deletions

View File

@ -24,7 +24,7 @@
<dependency> <dependency>
<groupId>top.wu2020</groupId> <groupId>top.wu2020</groupId>
<artifactId>wu-framework-web</artifactId> <artifactId>wu-framework-web</artifactId>
<version>1.1.9-JDK1.8-SNAPSHOT</version> <version>1.1.9-JDK1.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -70,9 +70,7 @@ public class ProxySocket {
}); });
log.info("连接服务端IP:{},连接服务端端口:{}",Constant.serverIp, Constant.serverPort); log.info("连接服务端IP:{},连接服务端端口:{}",Constant.serverIp, Constant.serverPort);
bootstrap.connect(Constant.serverIp, Constant.serverPort).addListener(new ChannelFutureListener() { bootstrap.connect(Constant.serverIp, Constant.serverPort).addListener((ChannelFutureListener) future -> {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) { if (future.isSuccess()) {
System.out.println("连接服务端成功"); System.out.println("连接服务端成功");
// 客户端链接代理服务器成功 // 客户端链接代理服务器成功
@ -117,7 +115,6 @@ public class ProxySocket {
} }
}, 2, TimeUnit.SECONDS); }, 2, TimeUnit.SECONDS);
} }
}
}); });
} }
} }

View File

@ -7,7 +7,9 @@ import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class RealSocket { public class RealSocket {
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup(); static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
@ -41,6 +43,7 @@ public class RealSocket {
} }
}); });
log.info("代理客户端本地端口:{}",Constant.realPort);
bootstrap.connect("127.0.0.1", Constant.realPort).addListener(new ChannelFutureListener() { bootstrap.connect("127.0.0.1", Constant.realPort).addListener(new ChannelFutureListener() {
@Override @Override
public void operationComplete(ChannelFuture future) throws Exception { public void operationComplete(ChannelFuture future) throws Exception {

View File

@ -34,7 +34,7 @@
<dependency> <dependency>
<groupId>top.wu2020</groupId> <groupId>top.wu2020</groupId>
<artifactId>wu-framework-web</artifactId> <artifactId>wu-framework-web</artifactId>
<version>1.1.9-JDK1.8-SNAPSHOT</version> <version>1.1.9-JDK1.8</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>