Netty UDP 使用采坑
使用Netty搭建UDP服务收集日志,使用过程中发现,部分日志接收不到,排查发现,都是大日志记录不到,后查询相关文档进行如下修改
EventLoopGroup workerGroup = new NioEventLoopGroup(20); try { Bootstrap b = new Bootstrap(); b.group(workerGroup); b.channel(NioDatagramChannel.class); b.option(ChannelOption.SO_BROADCAST, true); b.option(ChannelOption.SO_RCVBUF, 2048 * 2048); b.handler(udpInboundHandler); ChannelFuture f = b.bind(port).sync(); f.channel().closeFuture().sync(); } finally { workerGroup.shutdownGracefully(); }
添加缓存配置后,大日志就接收得到了
参考文档:
https://www.jianshu.com/p/975b30171352