| | |
| | | @Override |
| | | protected void initChannel(SocketChannel socketChannel) { |
| | | ChannelPipeline pipeline = socketChannel.pipeline(); |
| | | pipeline.addLast("heart", new IdleStateHandler(0, 5, 0, TimeUnit.SECONDS)); |
| | | pipeline.addLast("heart", new IdleStateHandler(5, 5, 0, TimeUnit.SECONDS)); |
| | | pipeline.addLast("encoder", new MessageProtocolEncoder()); |
| | | pipeline.addLast("decoder", new MessageProtocolDecoder()); |
| | | pipeline.addLast("handler", clientHandler); |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(fixedDelay = 10000) // 每 10 秒检查一次 |
| | | @Scheduled(fixedDelay = 5000) // 每 5 秒检查一次 |
| | | public void reconnectFailedServers() { |
| | | TyTcpServerCache.getTcpServerCacheMap().forEach((key, state) -> { |
| | | if (Boolean.FALSE.equals(state)) { // 连接失败的服务器 |