Browse Source

Merge pull request #15987 from thingsboard/fix_bug_sparkplug_cancel_session_after_node_connect

fix(sparkplug): close session after node connection
pull/16012/head
Viacheslav Klimov 3 weeks ago
committed by GitHub
parent
commit
6d81f29cf7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/session/AbstractGatewaySessionHandler.java

8
common/transport/mqtt/src/main/java/org/thingsboard/server/transport/mqtt/session/AbstractGatewaySessionHandler.java

@ -845,7 +845,13 @@ public abstract class AbstractGatewaySessionHandler<T extends AbstractGatewayDev
}
}
if (msgId <= 0) {
closeDeviceSession(deviceName, MqttReasonCodes.Disconnect.MALFORMED_PACKET);
if (deviceSessionCtx.isSparkplug()) {
// Sparkplug devices may use msgId = 0 during the initial connection or for QoS 0 messages. We bypass the MALFORMED_PACKET check to allow these sessions to proceed.
log.trace("[{}] Sparkplug session: allowed msgId [{}] for device: [{}]", sessionId, msgId, deviceName);
} else {
// Standard MQTT defense: close session for invalid message IDs
closeDeviceSession(deviceName, MqttReasonCodes.Disconnect.MALFORMED_PACKET);
}
}
}

Loading…
Cancel
Save