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
Assertion failure in "curl_ws_recv" #10347
Labels
Comments
CURLcode result = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);
I don't think this is related to the problem, but the code should check the
bytesleft field of the meta struct to see if all the data in the fragment has
been received. If not, then curl_ws_recv has to be called again to receive more
data.
My gut feeling is that the assert in the code isn't right (this is
experimental, after all) but I'm not really familiar with the WebSocket
support. Does the problem go away if you increase the size of buffer? Could you
enable debug logging and show what you get?
I don't quite see how the existing logic in curl_ws_recv is supposed to work.
If ws_decode decodes a full frame, oleft (and therefore wsp->frame.bytesleft)
will be 0 and the decoded data length datalen will be >0, so the assertion
DEBUGASSERT(wsp->frame.bytesleft >= datalen) will of course fail. At the point
of the assert, wsp->frame.bytesleft already contains only the remaining bytes
so the subtraction bytesleft -= datalen two lines down (as well as the assert
that's protecting the subtraction) shouldn't be necessary. I'm probably missing
something.
|
Increasing the buffer size doesn't make the assertion failure problem disappear. I also did the opposite. The meta->bytesleft always returns 0, even if I set the buffer size to be a small number, such as 10. The existing logic of updating the "wsp->frame. bytesleft" inside 'curl_ws_recv' might be flawed. |
bagder
added a commit
that referenced
this issue
Jan 30, 2023
Reported-by: Stanley Wucw Fixes #10347
See #10366 for a possible fix. It makes your test case run fine for me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did this
I was trying to receive data from a remote WebSocket server, but I got a debug assertion error.
The code below is running in debug mode in Visual Studio 2022:
I expected the following
The free WebSocket server "wss://ws.postman-echo.com/raw" is an echo server. It sends back whatever it received.
In the above code, the content of the variable "buffer" should be "{"message": "Hello to libcurl!"}" which was returned successfully by the API call "curl_ws_recv." However, that happened only after I closed the pop-up warnings and clicked the "ignore" button. See the image below.
In the release mode of Visual Studio 2022, the above warning pop-up doesn't show.
curl/libcurl version
7.87
operating system
Windows 10 with the latest update
The text was updated successfully, but these errors were encountered: