Browse Source

MQTT: fix unsubscribe error without previous subscribe (#12575)

improved formatting and moved check to recordActivityInternal.

Added warn log and check on provision

Updated license format
pull/12631/head
artem-barysh-dev 2 years ago
committed by GitHub
parent
commit
3370935be8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/MqttTransportHandler.java
  2. 6
      common/transport/transport-api/src/main/java/org/thingsboard/server/common/transport/service/DefaultTransportService.java

2
common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/MqttTransportHandler.java

@ -963,7 +963,7 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
unSubResults.add((short) MqttReasonCodes.UnsubAck.NO_SUBSCRIPTION_EXISTED.byteValue()); unSubResults.add((short) MqttReasonCodes.UnsubAck.NO_SUBSCRIPTION_EXISTED.byteValue());
} }
} }
if (!activityReported) { if (!activityReported && !deviceSessionCtx.isProvisionOnly()) {
transportService.recordActivity(deviceSessionCtx.getSessionInfo()); transportService.recordActivity(deviceSessionCtx.getSessionInfo());
} }
ctx.writeAndFlush(createUnSubAckMessage(mqttMsg.variableHeader().messageId(), unSubResults)); ctx.writeAndFlush(createUnSubAckMessage(mqttMsg.variableHeader().messageId(), unSubResults));

6
common/transport/transport-api/src/main/java/org/thingsboard/server/common/transport/service/DefaultTransportService.java

@ -736,7 +736,11 @@ public class DefaultTransportService extends TransportActivityManager implements
} }
private void recordActivityInternal(TransportProtos.SessionInfoProto sessionInfo) { private void recordActivityInternal(TransportProtos.SessionInfoProto sessionInfo) {
onActivity(toSessionId(sessionInfo), sessionInfo, getCurrentTimeMillis()); if (sessionInfo != null) {
onActivity(toSessionId(sessionInfo), sessionInfo, getCurrentTimeMillis());
} else {
log.warn("Session info is missing, unable to record activity");
}
} }
@Override @Override

Loading…
Cancel
Save