Skip to content

Update websocket.h function "void do_read()"#383

Open
nowgoing wants to merge 2 commits intoipkn:masterfrom
nowgoing:master
Open

Update websocket.h function "void do_read()"#383
nowgoing wants to merge 2 commits intoipkn:masterfrom
nowgoing:master

Conversation

@nowgoing
Copy link
Copy Markdown

Reason for update:

When state_ == WebSocketReadState::Payload, The function async_read_some() is not guaranteed to read all the data.
When remaining_length_ != 0 , you need to continue reading.

@mrozigor
Copy link
Copy Markdown

Can you write UT to show that problem exists? Because it looks like state isn't changed from WebSocketReadState::Payload, when remaining_length is different than 0. So it looks like staying in mentioned state up to point, when length equals 0.

@nowgoing
Copy link
Copy Markdown
Author

nowgoing commented Aug 18, 2020

Add test code print log

image

The log output is as follows

image
When remaining_length_ != 0 , websocket will stop reading.

@mrozigor
Copy link
Copy Markdown

But it's weird that moment earlier same amount of data are read at once.

@nowgoing
Copy link
Copy Markdown
Author

So async_read_some() is not guaranteed to read the message data;The above problem occurs when binary audio data is transmitted using WebSocket, with 25 packets per second。

@mrozigor
Copy link
Copy Markdown

That's true. But you can only add else block, without assigning state_ variable.

@mrozigor
Copy link
Copy Markdown

Thanks! I've merged it to my fork :)

GerHobbelt pushed a commit to GerHobbelt/crow that referenced this pull request Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants