Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nowgoing
Copy link

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

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
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

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

@nowgoing
Copy link
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

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

@mrozigor
Copy link

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants