| | |
| | | |
| | | @Override |
| | | public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { |
| | | // LogUtil.info("[websocket服务器收到消息]-->{}, {}", ctx.channel().id(), msg); |
| | | // log.info("[websocket服务器收到消息]-->{}, {}", ctx.channel().id(), msg); |
| | | if (msg instanceof FullHttpRequest) { |
| | | // 以http请求形式接入,但是走的是websocket |
| | | handleHttpRequest(ctx, (FullHttpRequest) msg); |
| | |
| | | @Override |
| | | public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { |
| | | log.info("[触发器触发]"); |
| | | // super.userEventTriggered(ctx, evt); |
| | | if (evt instanceof IdleStateEvent) { |
| | | IdleStateEvent event = (IdleStateEvent) evt; |
| | | if (event.state() == IdleState.READER_IDLE) { |
| | |
| | | times = 0; |
| | | } |
| | | /*读超时*/ |
| | | log.info("===服务端===({}写超时, {})", ctx.channel().id().asShortText(), times); |
| | | // log.info("===服务端===({}写超时, {})", ctx.channel().id().asShortText(), times); |
| | | // 失败计数器次数大于等于3次的时候,关闭链接,等待client重连 |
| | | if (times >= MAX_UN_REC_PING_TIMES) { |
| | | log.info("===服务端===(写超时,关闭chanel)"); |