|
|
@@ -10,7 +10,6 @@ import io.netty.channel.EventLoopGroup;
|
|
|
import io.netty.channel.nio.NioEventLoopGroup;
|
|
|
import io.netty.channel.socket.SocketChannel;
|
|
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
|
|
-import io.netty.handler.timeout.IdleStateHandler;
|
|
|
import io.netty.handler.timeout.ReadTimeoutHandler;
|
|
|
import io.netty.util.concurrent.DefaultEventExecutorGroup;
|
|
|
import io.netty.util.concurrent.EventExecutorGroup;
|
|
|
@@ -21,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
@@ -30,6 +28,8 @@ public class NettyServerThread {
|
|
|
private int port;
|
|
|
@Value("${collection.worker-threads:16}")
|
|
|
private int businessThreads = 16;
|
|
|
+ @Value("${device.connection.read-timeout-seconds:60}")
|
|
|
+ private int connectionReadTimeoutSeconds = 60;
|
|
|
private static Logger logger = LoggerFactory.getLogger(NettyServerThread.class);
|
|
|
private final MessageHandler messageHandler;
|
|
|
@Autowired
|
|
|
@@ -85,7 +85,9 @@ public class NettyServerThread {
|
|
|
}
|
|
|
|
|
|
public void configurePipeline(io.netty.channel.ChannelPipeline pipeline, EventExecutorGroup business) {
|
|
|
- pipeline.addLast(new ReadTimeoutHandler(3600));// 1小时内没有从通道(Channel)读取到任何数据则断开
|
|
|
+ // 只关闭超时连接,设备离线由独立巡检按最后有效上报判定。
|
|
|
+ pipeline.addLast(new ReadTimeoutHandler(connectionReadTimeoutSeconds > 0 ? connectionReadTimeoutSeconds : 60,
|
|
|
+ java.util.concurrent.TimeUnit.SECONDS));
|
|
|
pipeline.addLast(new DeviceFrameDecoder(DeviceFrameDecoder.Protocol.MANHOLE));
|
|
|
pipeline.addLast(business, messageHandler);
|
|
|
}
|