[Libwebsockets] multiple clients with http body using http persistent connection (PIPELINE)

Andy Green andy at warmcat.com
Thu Jan 30 20:01:37 CET 2020



On 1/28/20 12:06 PM, dev akira wrote:
> Hello Andy,
> 
> Thank you for your quick answer!
> 
> The sample codes helped me a lot to understand how to use libwebsockets 
> and it would be helpful if you add an option to send http body to the 
> http-client-multi example.

On master, ther minimal-http-client-multi example now supports --post, 
and I added 6 variations of it to the CI selftests as well, mixing h1, 
h2, stagger and pipeline.

Hopefully this is working now, please give it a try.

-Andy

> 
> Thank you,
> Akira
> 
> 2020年1月28日(火) 20:32 Andy Green <andy at warmcat.com 
> <mailto:andy at warmcat.com>>:
> 
> 
> 
>     On 1/28/20 11:19 AM, dev akira wrote:
>      > Hello,
>      >
>      > I would like to make multi clients connect a server (with the same
>      > address and port), sequentially with multiple paths and methods.
>     I can
>      > implement the code but every client setup it's own tcp connection
>     (and
>      > tls tunnel). Now, I would like to make a http persistent connection
>      > using a single tcp connection (and a single tls tunnel).
>      >
>      > I tried LCCSCF_PIPELINE but did not work when the clients has
>     http body.
> 
>     It's the correct way for either h1 or h2, if the problem is coming when
>     sending a POST body or whatever it sounds like a bug.
> 
>      > For example, when I make a http request with http body using
>      > lws_client_connect_via_info(). This generates a wsi (1) and complets
>      > client http. Then, make a second http with http body using
>      > lws_client_connect_via_info(). This generates another wsi (2) but
>      > results in "lws_callback_on_writable(): failed to find socket -1"
>     and
>      > cannot make the callback function called with
>      > LWS_CALLBACK_CLIENT_HTTP_WRITEABLE(57) to send http body.
>      >
>      > I searched libwebsockets docs, sample codes, mailinglist but
>     cannot find it.
> 
>     This is the example used to confirm the connection binding
> 
>     https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/http-client/minimal-http-client-multi
> 
>     it runs with various options during CI tests for each push.  But it
>     doesn't support testing with POST atm.
> 
>      > <<< call lws_client_http_body_pending(wsi, 1)  in callback function
> 
>     Right...
> 
>     I think the best move is I'll add an option for this kind of behaviour
>     to the http-client-multi example and see what happens.  Broadly the
>     connections are doing the same thing as if they are standalone, but
>     there are some differences, if there's a bug it's probably related
>     to that.
> 
>     -Andy
> 


More information about the Libwebsockets mailing list