mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
update mqtt 服务器
This commit is contained in:
@@ -64,41 +64,9 @@ public class NettyServer implements CommandLineRunner {
|
||||
} else {
|
||||
log.error("NettyServer启动失败", future.cause());
|
||||
}
|
||||
//
|
||||
// ServerBootstrap mqttBootstrap = new ServerBootstrap();
|
||||
// mqttBootstrap.group(bossGroup, workerGroup);
|
||||
// mqttBootstrap.channel(NioServerSocketChannel.class);
|
||||
//
|
||||
// mqttBootstrap.option(ChannelOption.SO_REUSEADDR, true)
|
||||
// .option(ChannelOption.SO_BACKLOG, 1024)
|
||||
// .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
|
||||
// .option(ChannelOption.SO_RCVBUF, 10485760);
|
||||
//
|
||||
// mqttBootstrap.childOption(ChannelOption.TCP_NODELAY, true)
|
||||
// .childOption(ChannelOption.SO_KEEPALIVE, true)
|
||||
// .childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
|
||||
//
|
||||
// mqttBootstrap.childHandler(new ChannelInitializer<SocketChannel>() {
|
||||
// protected void initChannel(SocketChannel ch) {
|
||||
// ChannelPipeline channelPipeline = ch.pipeline();
|
||||
// // 设置读写空闲超时时间
|
||||
// channelPipeline.addLast(new IdleStateHandler(600, 600, 1200));
|
||||
// channelPipeline.addLast("encoder", MqttEncoder.INSTANCE);
|
||||
// channelPipeline.addLast("decoder", new MqttDecoder());
|
||||
// channelPipeline.addLast(new BootNettyMqttChannelInboundHandler());
|
||||
// }
|
||||
// });
|
||||
// ChannelFuture future2 = mqttBootstrap.bind(address2.getPort()).sync();
|
||||
// if(future2.isSuccess()){
|
||||
// log.info("MqttServer启动成功, 开始监听端口:{}", address2.getPort());
|
||||
// future2.channel().closeFuture().sync();
|
||||
// } else {
|
||||
// log.error("MqttServer启动失败", future2.cause());
|
||||
// }
|
||||
|
||||
//关闭channel和块,直到它被关闭
|
||||
future.channel().closeFuture().sync();
|
||||
// future2.channel().closeFuture().sync();
|
||||
// 关闭channel和块,直到它被关闭 (若取消注释,则 MQTT 服务器无法启动)
|
||||
// future.channel().closeFuture().sync();
|
||||
} catch (Exception e) {
|
||||
log.error("NettyServer.start error", e);
|
||||
bossGroup.shutdownGracefully();
|
||||
|
||||
Reference in New Issue
Block a user