curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

RV: is it posible using websocket API with multi handlers with select?

From: Josť Luis Zabalza Cestau via curl-library <curl-library_at_lists.haxx.se>
Date: Wed, 2 Aug 2023 08:34:48 +0000

________________________________
De: curl-library <curl-library-bounces_at_lists.haxx.se> en nombre de Josť Luis Zabalza Cestau via curl-library <curl-library_at_lists.haxx.se>
Enviado: martes, 1 de agosto de 2023 9:27
Para: Daniel Stenberg <daniel_at_haxx.se>; Josť Luis Zabalza Cestau via curl-library <curl-library_at_lists.haxx.se>
Cc: Josť Luis Zabalza Cestau <jzabalza_at_naitec.es>
Asunto: RE: is it posible using websocket API with multi handlers with select?

Correo enviado desde un remitente externo.
Considera este correo como potencialmente peligroso si contiene adjuntos o enlaces a direcciones de internet



Thanks Daniel but I don't think it is a bug. I think something is missing in the code.

I attatch a NODE WebServer example (tar.bz2) using https://github.com/websockets/ws library and a multy-legacy.c modified code.

wssserver.js set up a little web server with two functions
- http://localhost:8080/query return a json object (query data)
- ws://localhost:8080/ws begins a websocket connection. Firstly, it sends a json object (Connection Data) and then it continues periodicaly sending another json object (Periodic data) every second.

multi-legacy-ws.c is a bit complicated. It begins printing a menu and waiting for a keyboard command.

- "q" command exit the application.
- "h" command prints menu.
- "p" command sends a http://localhost:8080/query get request
- "w" command begins a websocket only connection to ws://localhost:8080/ws

multi-legacy-ws.c: has a main while loop waiting for quit command and internaly has a loop waiting for select actions, keyboard or multi curl handlers actions. When a action is found, it gets out of the select loop and it check if is a keyboard action or curl action.

When a curl handler action is found, a curl_multi_info_read() loop begins for get the curl handler actions. If WS handler transfer is complete, the received data is read with curl_ws_recv() function.

Now, I think I have to do something but I don't know what for "reload" the WS handler. I try remove and add WS handler from the multi handler, but don't work.

Thanks for the help.

Note: I am using libcurl 7.88.1 on Ubuntu 22.04.2 LTS







________________________________
De: Daniel Stenberg <daniel_at_haxx.se>
Enviado: lunes, 31 de julio de 2023 17:51
Para: Josť Luis Zabalza Cestau via curl-library <curl-library_at_lists.haxx.se>
Cc: Josť Luis Zabalza Cestau <jzabalza_at_naitec.es>
Asunto: Re: is it posible using websocket API with multi handlers with select?

Correo enviado desde un remitente externo.
Considera este correo como potencialmente peligroso si contiene adjuntos o enlaces a direcciones de internet



On Mon, 31 Jul 2023, Josť Luis Zabalza Cestau via curl-library wrote:

> My first try was a modified https://curl.se/libcurl/c/multi-legacy.html
> example. I can read a command from keyboard, send a http query, and connect
> to websocket, at time but periodic data received form websocket don't wakeap
> the select.

That sounds like a bug!

Do you have a way (for us) to reproduce this? Can to submit this as a new
issue over at https://github.com/curl/curl/issues ?

--
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html





-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-08-02