分两步:
第1步,调整linux下/etc/sysctl.conf参数,里面增加
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 5
然后执行sysctl -p 让它立即生效
第2步,修改netty启动TCP参数ChannelOption
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.childOption(ChannelOption.SO_REUSEADDR, true);
bootstrap.childOption(ChannelOption.SO_LINGER,null);
网友评论