Commit 3fec1a2ddabcb40745ee8f79c98beb6aacebdd85

Authored by nordmif
1 parent 42718d4e

fixed mqtt keep-alive

... ... @@ -466,6 +466,7 @@ transport:
466 466 boss_group_thread_count: "${NETTY_BOSS_GROUP_THREADS:1}"
467 467 worker_group_thread_count: "${NETTY_WORKER_GROUP_THREADS:12}"
468 468 max_payload_size: "${NETTY_MAX_PAYLOAD_SIZE:65536}"
  469 + so_keep_alive: "${NETTY_SO_KEEPALIVE:true}"
469 470 # MQTT SSL configuration
470 471 ssl:
471 472 # Enable/disable SSL support
... ...
... ... @@ -17,6 +17,7 @@ package org.thingsboard.server.transport.mqtt;
17 17
18 18 import io.netty.bootstrap.ServerBootstrap;
19 19 import io.netty.channel.Channel;
  20 +import io.netty.channel.ChannelOption;
20 21 import io.netty.channel.EventLoopGroup;
21 22 import io.netty.channel.nio.NioEventLoopGroup;
22 23 import io.netty.channel.socket.nio.NioServerSocketChannel;
... ... @@ -50,6 +51,8 @@ public class MqttTransportService {
50 51 private Integer bossGroupThreadCount;
51 52 @Value("${transport.mqtt.netty.worker_group_thread_count}")
52 53 private Integer workerGroupThreadCount;
  54 + @Value("${transport.mqtt.netty.so_keep_alive}")
  55 + private boolean keepAlive;
53 56
54 57 @Autowired
55 58 private MqttTransportContext context;
... ... @@ -69,7 +72,8 @@ public class MqttTransportService {
69 72 ServerBootstrap b = new ServerBootstrap();
70 73 b.group(bossGroup, workerGroup)
71 74 .channel(NioServerSocketChannel.class)
72   - .childHandler(new MqttTransportServerInitializer(context));
  75 + .childHandler(new MqttTransportServerInitializer(context))
  76 + .childOption(ChannelOption.SO_KEEPALIVE, keepAlive);
73 77
74 78 serverChannel = b.bind(host, port).sync().channel();
75 79 log.info("Mqtt transport started!");
... ...