Skip to content

Commit

Permalink
-- mqtt协议解析剩余长度判断不一致,导致解析异常connection 断连 (#81)
Browse files Browse the repository at this point in the history
Co-authored-by: levili <wei.li02@narwal.com>
  • Loading branch information
levili-T and levili committed Jan 21, 2024
1 parent d065797 commit 128ae14
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/src/utility/mqtt_byte_buffer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ class MqttByteBuffer {
var position = _position;
var header = MqttHeader.fromByteBuffer(this);
// Restore the position
final avibytes = availableBytes; // should same in MqttMessage.createFrom
_position = position;
if (availableBytes < header.messageSize) {
if (avibytes < header.messageSize) {
MqttLogger.log(
'MqttByteBuffer:isMessageAvailable - Available bytes($availableBytes) is less than the message size'
'MqttByteBuffer:isMessageAvailable - Available bytes($avibytes) is less than the message size'
' ${header.messageSize}');

return false;
Expand Down

0 comments on commit 128ae14

Please sign in to comment.