Commit 1f4db17f authored by duanruiming's avatar duanruiming

[update] 绑定本地固定端口

parent 6889e078
......@@ -41,8 +41,9 @@ public class NettyClient {
bootstrap.group(group)
.channel(NioDatagramChannel.class)
.option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(65535))
.localAddress(5051)
.remoteAddress(new InetSocketAddress("10.102.1.204", 5050))
// .localAddress(new InetSocketAddress(5051))
// 绑定bending端口
.remoteAddress(new InetSocketAddress(5051))
.handler(new ChannelInitializer<NioDatagramChannel>() {
@Override
protected void initChannel(NioDatagramChannel datagramChannel) {
......@@ -50,7 +51,7 @@ public class NettyClient {
.addLast(new NettyServerHandler(threadPoolExecutor));
}
});
ChannelFuture channelFuture = bootstrap.bind().sync();
ChannelFuture channelFuture = bootstrap.bind(5050).sync();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
group.shutdownGracefully();
channelFuture.channel().closeFuture().syncUninterruptibly();
......
......@@ -81,6 +81,11 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<DatagramPack
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
super.exceptionCaught(ctx, cause);
}
private CommandPojo getCommandPojo(String key, String data) {
CrossInfoPO crossInfo = crossInfoCache.getCrossInfo(key);
CommandPojo commandPojo = new CommandPojo();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment