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

dev akira akira.pp.dev at gmail.com
Fri Jan 31 08:28:19 CET 2020


Hello Andy,

Thank you very much for updating sample code of minimal-http-client-multi.

Using the latest code (70794eaf: minimal-http-client-multi: add POST), I
executed "./minimal-http-client-multi -l -p --h1 --post" and confirmed the
multiple clients connected to the server with a single tls tunnel.

On the other hand, when I executed "./minimal-http-client-multi -l -p -s
--h1 --post" (with staggered option), multiple clients use their own tls
tunnels.
Is there any way to share a single tls tunnel even for the above scenario?


I also confirmed the behavior of minimal-http-client-multi with staggerd
option using the latest code and the previous one.
I executed "./minimal-http-client-multi -l -p -s --h1" using each code and
found below:
The latest code: 8 clients uses 8 tls tunnels.
The previous code: 8 clients uses 1 tls tunnel.

Is this behavior designed?

Log: the latest code
==============================================================
[2020/01/31 08:39:40:6789] I: Libwebsockets version: 3.2.99
v3.1.0-499-g70794eaf
------
[2020/01/31 08:39:40:7844] I: lws_client_connect_via_info: wsi 0x18cdfe0:
h1 http entry
...
[2020/01/31 08:39:40:7864] I: client connect OK
[2020/01/31 08:39:40:7864] I: lws_openssl_describe_cipher: wsi 0x18cdfe0:
ECDHE-RSA-AES256-GCM-SHA384, ECDHE-RSA-AES256-GCM-SHA384, 256 bits, TLSv1.2
...
[2020/01/31 08:39:40:7892] U: LWS_CALLBACK_COMPLETED_CLIENT_HTTP 0x18cdfe0:
idx 0
[2020/01/31 08:39:40:7892] I:
_lws_generic_transaction_completed_active_conn: nothing pipelined waiting
------
[2020/01/31 08:39:41:0850] I: lws_client_connect_via_info: wsi 0x18cb490:
h1 http entry
...
[2020/01/31 08:39:41:0851] N:
_lws_generic_transaction_completed_active_conn: pipeline queue passed wsi
0x18cdfe0 on to queued wsi 0x18cb490
...
[2020/01/31 08:39:41:0851] I: client connect OK
[2020/01/31 08:39:41:0851] I: lws_openssl_describe_cipher: wsi 0x18cb490:
ECDHE-RSA-AES256-GCM-SHA384, ECDHE-RSA-AES256-GCM-SHA384, 256 bits, TLSv1.2
...
[2020/01/31 08:39:41:0902] U: LWS_CALLBACK_COMPLETED_CLIENT_HTTP 0x18cb490:
idx 1
[2020/01/31 08:39:41:0902] I:
_lws_generic_transaction_completed_active_conn: nothing pipelined waiting
------
[2020/01/31 08:39:41:3856] I: lws_client_connect_via_info: wsi 0x18cdfe0:
h1 http entry
...
[2020/01/31 08:39:41:3881] I: client connect OK
[2020/01/31 08:39:41:3881] I: lws_openssl_describe_cipher: wsi 0x18cdfe0:
ECDHE-RSA-AES256-GCM-SHA384, ECDHE-RSA-AES256-GCM-SHA384, 256 bits, TLSv1.2
...
[2020/01/31 08:39:41:3918] U: LWS_CALLBACK_COMPLETED_CLIENT_HTTP 0x18cdfe0:
idx 2
[2020/01/31 08:39:41:3918] I:
_lws_generic_transaction_completed_active_conn: nothing pipelined waiting
------
......
==============================================================


Log: the previous code
==============================================================
[2020/01/31 13:40:23:1167] I: Libwebsockets version: 3.2.99
v3.1.0-498-ga92a295c
------
[2020/01/31 13:40:23:2223] I: lws_client_connect_via_info: wsi 0x1791e80:
h1 http entry
...
[2020/01/31 13:40:23:2246] I: client connect OK
[2020/01/31 13:40:23:2246] I: lws_openssl_describe_cipher: wsi 0x1791e80:
ECDHE-RSA-AES256-GCM-SHA384, ECDHE-RSA-AES256-GCM-SHA384, 256 bits, TLSv1.2
...
[2020/01/31 13:40:23:2249] U: LWS_CALLBACK_COMPLETED_CLIENT_HTTP 0x1791e80:
idx 0
[2020/01/31 13:40:23:2249] I:
_lws_generic_transaction_completed_active_conn: nothing pipelined waiting
------
[2020/01/31 13:40:23:5229] I: lws_client_connect_via_info: wsi 0x178f210:
h1 http entry
...
[2020/01/31 13:40:23:5234] U: LWS_CALLBACK_COMPLETED_CLIENT_HTTP 0x178f210:
idx 1
...
[2020/01/31 13:40:23:5234] I:
_lws_generic_transaction_completed_active_conn: nothing pipelined waiting
------
[2020/01/31 13:40:23:8230] I: lws_client_connect_via_info: wsi 0x178f210:
h1 http entry
...
[2020/01/31 13:40:23:8234] U: LWS_CALLBACK_COMPLETED_CLIENT_HTTP 0x178f210:
idx 2
...
[2020/01/31 13:40:23:8235] I:
_lws_generic_transaction_completed_active_conn: nothing pipelined waiting
------
......
==============================================================

I used a same Linux environment for each execution.

Thank you,
Akira

2020年1月31日(金) 4:01 Andy Green <andy at warmcat.com>:

>
>
> 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
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20200131/d9a53f14/attachment.htm>


More information about the Libwebsockets mailing list