From 54d4d91c3fb770688a349e6974eeeff0d50c7c8a Mon Sep 17 00:00:00 2001
From: Timo Tiuraniemi <timo.tiuraniemi@iki.fi>
Date: Sun, 19 Nov 2023 11:07:33 +0200
Subject: [PATCH] Fix excess warnings with message decoding length for
 Open/Close messages.

---
 src/message.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/message.rs b/src/message.rs
index 30344d6..dc73925 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -124,7 +124,9 @@ impl Frame {
                         )?;
                         if length != body_len as usize {
                             tracing::warn!(
-                                "Did not know what to do with all the bytes, got {} but decoded {}",
+                                "Did not know what to do with all the bytes, got {} but decoded {}. \
+                                This may be because the peer implements a newer protocol version \
+                                that has extra fields.",
                                 body_len,
                                 length
                             );
@@ -202,11 +204,11 @@ impl Frame {
             } else if buf[1] == 0x01 {
                 // Open message
                 let (channel_message, length) = ChannelMessage::decode_open_message(&buf[2..])?;
-                Ok((Frame::MessageBatch(vec![channel_message]), length))
+                Ok((Frame::MessageBatch(vec![channel_message]), length + 2))
             } else if buf[1] == 0x03 {
                 // Close message
                 let (channel_message, length) = ChannelMessage::decode_close_message(&buf[2..])?;
-                Ok((Frame::MessageBatch(vec![channel_message]), length))
+                Ok((Frame::MessageBatch(vec![channel_message]), length + 2))
             } else {
                 Err(io::Error::new(
                     io::ErrorKind::InvalidData,