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

websocket.c example: curl_ws_recv returns "Socket not ready for send/recv" (errno 81) #13288

Open
untitaker opened this issue Apr 4, 2024 · 1 comment

Comments

@untitaker
Copy link

untitaker commented Apr 4, 2024

I did this

  1. copied this example into foo.c
  2. edited the websocket URL in 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 as websocat -s 8080
  3. cloned curl master, moved foo.c into root folder
  4. cmake -DENABLE_WEBSOCKETS=on
  5. make
  6. cc -L lib/ foo.c -lcurl
  7. 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:

ws: curl_ws_recv returned 81, received 0

in the real-world application that is built based on that example code, I get (just posting the strerror for searchability):

code 81: "Socket not ready for send/recv"

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, though websocket.c does not exist on that commit at all anyway

operating system

Ubuntu 23.10

@untitaker
Copy link
Author

untitaker commented Apr 4, 2024

Dug around a little, and I suspect that this is intended behavior due to #10625, and it's just the example that needs updating, similar to #10760

though I'm not sure a crude busy-loop is a good example to follow either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants