-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Websocket fails to keep connected when using curl_multi API #15780
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
Comments
curl_multi_info_read doesn't work like that: When you fetch a message using this function, it is removed from the internal queue so calling this function again does not return the same message again. You've possibly received and then sent a message (there's no check for CURLE_AGAIN) and then that block is never reached again because curl_multi_info_read has already popped off that handle from its queue. IMO the way you are doing it is the wrong way to go about it. I would use normal websocket mode instead of connect-only mode. The latter is harder to use and with the former you can read messages in your writefunction and then once you have the data you need you can from that same function send messages that will be fully sent because curl_ws_send is blocking when called from a writefunction callback. although i'm not an expert with websockets so others may want to chime in here please see https://curl.se/libcurl/c/libcurl-ws.html and https://curl.se/libcurl/c/curl_ws_send.html |
When I connect to wss://echo.websocket.org/, I do get a message
If I don't do connect-only mode. The I can't do blocking mode with callbacks as I do have another loop in my program and I prefer to poll with timeout. |
message is null because there are no more messages. The way libcurl works internally there's currently only a single message that the handle is done and that's it. Even if that wasn't so, like you add more handles or more messages types are defined in the future, then that block of code is still wrong. The outer loop exits as well which is also wrong for this case. (edit: may be wrong for this case, depends on what his code actually does) You have asked libcurl to "connect only" for a websocket transfer and assuming CURLMSG_DONE and |
Well, Anway, if |
I did this
I was trying to write a small program using libcurl websocket API. When using the curl_multi APIs, it seems to be returning after some time (instead of blocking until close/error):
C source for the test
I expected the following
websocket is supposed to stay connected until the client/server initiates close request/on error. The the application should be running, and I should be receiving an echo of the message send to the websocket.org echo service.
curl/libcurl version
8.11.1-1 (as packaged in Debian) and 9fce2c5 from master (tested with jhbuild)
operating system
Debian GNU/Linux sid
The text was updated successfully, but these errors were encountered: