Skip to content

Fragmented receive issues for UTF8 messages #3

@PerditionC

Description

@PerditionC

Public Function GetMessageUTF8() As String

In GetMessageUTF8, if the receive returns a fragmented message, it is not handled well. The next iteration of the loop will overwrite the whole buffer replacing the initial received bytes. My initial fix was to increase the buffer size and track where in the buffer (which it looks like at some point that is/was the intent) but it was lost. This however has issues as the buffer size can't be known in advance usually, so throws error with buffer to small on replies larger than the message (which Chrome/Edge can return JSON messages over 4KB). So instead I convert the portion received to a string and concatenate with previously received portions (already converted). This however can cause issues if the message is fragmented in the middle of a utf8 sequence. I look for the start of the last lead byte and see how many bytes are actually sent and keep that in the buffer starting the next receive just past them. (I'm still testing my implementation of this).

Would you be interested in a pull request that reworks GetMessageUTF8 so it better handles fragmented messages?
You can see current my implementation here: https://github.com/PerditionC/VBAChromeDevProtocol/blob/b2ebd19b606b450fea8c3996ca82ca01e5ac3afd/src/clsWebSocket.cls#L570

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions