Commit 0fa963be85c657eb6b57c4dc5303cdf59e9c2e0a
Committed by
Andrew Shvayka
1 parent
07eaf4dd
fix bug:Device reconnect abnormal when certificate authentication is turned on
Showing
2 changed files
with
5 additions
and
5 deletions
@@ -100,12 +100,12 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement | @@ -100,12 +100,12 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement | ||
100 | private volatile DeviceSessionCtx deviceSessionCtx; | 100 | private volatile DeviceSessionCtx deviceSessionCtx; |
101 | private volatile GatewaySessionHandler gatewaySessionHandler; | 101 | private volatile GatewaySessionHandler gatewaySessionHandler; |
102 | 102 | ||
103 | - MqttTransportHandler(MqttTransportContext context) { | 103 | + MqttTransportHandler(MqttTransportContext context,SslHandler sslHandler) { |
104 | this.sessionId = UUID.randomUUID(); | 104 | this.sessionId = UUID.randomUUID(); |
105 | this.context = context; | 105 | this.context = context; |
106 | this.transportService = context.getTransportService(); | 106 | this.transportService = context.getTransportService(); |
107 | this.adaptor = context.getAdaptor(); | 107 | this.adaptor = context.getAdaptor(); |
108 | - this.sslHandler = context.getSslHandler(); | 108 | + this.sslHandler = sslHandler; |
109 | this.mqttQoSMap = new ConcurrentHashMap<>(); | 109 | this.mqttQoSMap = new ConcurrentHashMap<>(); |
110 | this.deviceSessionCtx = new DeviceSessionCtx(sessionId, mqttQoSMap); | 110 | this.deviceSessionCtx = new DeviceSessionCtx(sessionId, mqttQoSMap); |
111 | } | 111 | } |
@@ -36,15 +36,15 @@ public class MqttTransportServerInitializer extends ChannelInitializer<SocketCha | @@ -36,15 +36,15 @@ public class MqttTransportServerInitializer extends ChannelInitializer<SocketCha | ||
36 | @Override | 36 | @Override |
37 | public void initChannel(SocketChannel ch) { | 37 | public void initChannel(SocketChannel ch) { |
38 | ChannelPipeline pipeline = ch.pipeline(); | 38 | ChannelPipeline pipeline = ch.pipeline(); |
39 | + SslHandler sslHandler = null; | ||
39 | if (context.getSslHandlerProvider() != null) { | 40 | if (context.getSslHandlerProvider() != null) { |
40 | - SslHandler sslHandler = context.getSslHandlerProvider().getSslHandler(); | 41 | + sslHandler = context.getSslHandlerProvider().getSslHandler(); |
41 | pipeline.addLast(sslHandler); | 42 | pipeline.addLast(sslHandler); |
42 | - context.setSslHandler(sslHandler); | ||
43 | } | 43 | } |
44 | pipeline.addLast("decoder", new MqttDecoder(context.getMaxPayloadSize())); | 44 | pipeline.addLast("decoder", new MqttDecoder(context.getMaxPayloadSize())); |
45 | pipeline.addLast("encoder", MqttEncoder.INSTANCE); | 45 | pipeline.addLast("encoder", MqttEncoder.INSTANCE); |
46 | 46 | ||
47 | - MqttTransportHandler handler = new MqttTransportHandler(context); | 47 | + MqttTransportHandler handler = new MqttTransportHandler(context,sslHandler); |
48 | 48 | ||
49 | pipeline.addLast(handler); | 49 | pipeline.addLast(handler); |
50 | ch.closeFuture().addListener(handler); | 50 | ch.closeFuture().addListener(handler); |