-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
websocket.c example: curl_ws_recv returns "Socket not ready for send/recv" (errno 81) #13288
Labels
Comments
jay
added a commit
to jay/curl
that referenced
this issue
Jul 17, 2024
- Overhaul the recv_any function to block waiting for a complete websocket message from the server. - Have recv_pong and recv_header call recv_any to retrieve a complete message, rather than duplicate the efforts in each function. - Fix sleep() macro for Windows to treat the parameter as seconds instead of milliseconds. - Improve documentation of curl_ws_recv/send to better explain CURLE_AGAIN behavior. - Use echo.websocket.org instead of example.com as the example websocket server since it is a server the example actually works on. recv_any now calls curl_ws_recv repeatedly, waiting until the socket is readable and a full websocket message is read from the server. Prior to this change the example did not handle the non-blocking behavior of curl_ws_recv. When curl_ws_recv returned CURLE_AGAIN the example would fail with "socket not ready". Fixes curl#13288 Closes #xxxx
jay
added a commit
to jay/curl
that referenced
this issue
Jul 17, 2024
- Add function blocking_ws_recv which blocks waiting for a complete websocket message from the server. blocking_ws_recv calls curl_ws_recv repeatedly, waiting until the socket is readable and a full websocket message is read from the server. Prior to this change the example failed when curl_ws_recv returned CURLE_AGAIN. Fixes curl#13288 Closes #xxxx
jay
added a commit
to jay/curl
that referenced
this issue
Jul 19, 2024
- Overhaul the recv_any function to block waiting for a complete websocket message from the server. - Have recv_pong and recv_header call recv_any to retrieve a complete message, rather than duplicate the efforts in each function. - Fix sleep() macro for Windows to treat the parameter as seconds instead of milliseconds. - Improve documentation of curl_ws_recv/send to better explain CURLE_AGAIN behavior. - Use echo.websocket.org instead of example.com as the example websocket server since it is a server the example actually works on. recv_any now calls curl_ws_recv repeatedly, waiting until the socket is readable and a full websocket message is read from the server. Prior to this change the example did not handle the non-blocking behavior of curl_ws_recv. When curl_ws_recv returned CURLE_AGAIN the example would fail with "socket not ready". Fixes curl#13288 Closes #xxxx
jay
added a commit
to jay/curl
that referenced
this issue
Aug 4, 2024
- Overhaul the recv_any function to block waiting for a complete websocket message from the server. - Have recv_pong and recv_header call recv_any to retrieve a complete message, rather than duplicate the efforts in each function. - Fix sleep() macro for Windows to treat the parameter as seconds instead of milliseconds. - Improve documentation of curl_ws_recv/send to better explain CURLE_AGAIN behavior. - Use echo.websocket.org instead of example.com as the example websocket server since it is a server the example actually works on. recv_any now calls curl_ws_recv repeatedly, waiting until the socket is readable and a full websocket message is read from the server. Prior to this change the example did not handle the non-blocking behavior of curl_ws_recv. When curl_ws_recv returned CURLE_AGAIN the example would fail with "socket not ready". Fixes curl#13288 Closes #xxxx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did this
foo.c
foo.c
to be a valid websocket server.wss://ws.postman-echo.com/raw
works,ws://localhost:8080
works as well, with websocat being invoked aswebsocat -s 8080
foo.c
into root foldercmake -DENABLE_WEBSOCKETS=on
make
cc -L lib/ foo.c -lcurl
LD_LIBRARY_PATH=lib/ ./a.out
I expected the following
some kind of ping-pong demo, or a hanging connection, depending on which websocket server is being used.
instead the program immediately quits with this after sending the initial HTTP headers:
in the real-world application that is built based on that example code, I get (just posting the strerror for searchability):
curl/libcurl version
git sha 376cd67
I thought this was related to #11443, so I checked curl 7 as well. On tag
curl-7_88_1
(046209e),foo.c
hangs instead, thoughwebsocket.c
does not exist on that commit at all anywayoperating system
Ubuntu 23.10
The text was updated successfully, but these errors were encountered: