fix bug:Device reconnect abnormal when certificate authentication is turned on
This commit is contained in:
parent
07eaf4dd77
commit
0fa963be85
@ -100,12 +100,12 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
|
|||||||
private volatile DeviceSessionCtx deviceSessionCtx;
|
private volatile DeviceSessionCtx deviceSessionCtx;
|
||||||
private volatile GatewaySessionHandler gatewaySessionHandler;
|
private volatile GatewaySessionHandler gatewaySessionHandler;
|
||||||
|
|
||||||
MqttTransportHandler(MqttTransportContext context) {
|
MqttTransportHandler(MqttTransportContext context,SslHandler sslHandler) {
|
||||||
this.sessionId = UUID.randomUUID();
|
this.sessionId = UUID.randomUUID();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.transportService = context.getTransportService();
|
this.transportService = context.getTransportService();
|
||||||
this.adaptor = context.getAdaptor();
|
this.adaptor = context.getAdaptor();
|
||||||
this.sslHandler = context.getSslHandler();
|
this.sslHandler = sslHandler;
|
||||||
this.mqttQoSMap = new ConcurrentHashMap<>();
|
this.mqttQoSMap = new ConcurrentHashMap<>();
|
||||||
this.deviceSessionCtx = new DeviceSessionCtx(sessionId, mqttQoSMap);
|
this.deviceSessionCtx = new DeviceSessionCtx(sessionId, mqttQoSMap);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,15 +36,15 @@ public class MqttTransportServerInitializer extends ChannelInitializer<SocketCha
|
|||||||
@Override
|
@Override
|
||||||
public void initChannel(SocketChannel ch) {
|
public void initChannel(SocketChannel ch) {
|
||||||
ChannelPipeline pipeline = ch.pipeline();
|
ChannelPipeline pipeline = ch.pipeline();
|
||||||
|
SslHandler sslHandler = null;
|
||||||
if (context.getSslHandlerProvider() != null) {
|
if (context.getSslHandlerProvider() != null) {
|
||||||
SslHandler sslHandler = context.getSslHandlerProvider().getSslHandler();
|
sslHandler = context.getSslHandlerProvider().getSslHandler();
|
||||||
pipeline.addLast(sslHandler);
|
pipeline.addLast(sslHandler);
|
||||||
context.setSslHandler(sslHandler);
|
|
||||||
}
|
}
|
||||||
pipeline.addLast("decoder", new MqttDecoder(context.getMaxPayloadSize()));
|
pipeline.addLast("decoder", new MqttDecoder(context.getMaxPayloadSize()));
|
||||||
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
|
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
|
||||||
|
|
||||||
MqttTransportHandler handler = new MqttTransportHandler(context);
|
MqttTransportHandler handler = new MqttTransportHandler(context,sslHandler);
|
||||||
|
|
||||||
pipeline.addLast(handler);
|
pipeline.addLast(handler);
|
||||||
ch.closeFuture().addListener(handler);
|
ch.closeFuture().addListener(handler);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user