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

Andy Green andy at warmcat.com
Tue Jan 28 12:32:58 CET 2020



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