[Libwebsockets] Ways to send multiple client request on the same wsi

Xi Chen leon6827chix at gmail.com
Wed Aug 22 20:38:55 CEST 2018


Thanks for your reply Andy.

I have a few comments:
1. I quickly went thru the code (H2 client role specifically). For POLLIN,
the h2n->swsi will be set by received stream id (sid), then corresponding
h2 child wsi will be used.
For POLLOUT, it seems doing a round-robin manner to go thru all child list
of nwsi. Do I understand correctly?

2. I have already went thru the minimum-http-client-multi example. However,
from the debug log, I found that each client created its own socket (i.e.,
a nwsi and a child wsi). It seems the example creates multiple sockets
rather than reusing the same socket. What I need is one nwsi (one socket)
opened with multiple child wsi, each has its own sid value representing a
different H2 stream. I do not see such API existing. Can you help confirm?

To achieve this, seems I need to i) create new wsi; ii) add it in to nwsi's
child list; iii) lws_h2_client_handshake(new wsi). Correct?

Thanks
-Xi

On Tue, Aug 21, 2018 at 11:28 PM, Andy Green <andy at warmcat.com> wrote:

>
>
> On 08/21/2018 12:09 AM, Xi Chen wrote:
>
>> Hi,
>>
>> I have two issues (maybe observations) which needs some clarifications:
>>
>>  1.
>>
>>     Currently I send one H2 client request vis
>>     lws_client_connect_via_info(), it creates one network wsi (nwsi) and
>>     then one h2 child wsi (h2_wsi). When I return -1 in the callback, it
>>     frees h2_wsi only. Why nwsi is not close?
>>
>
> (I must say I am gratified to hear someone talk about nwsi.  After
> spending many months working on h2 support it's the first time someone read
> the code AFAIK.)
>
> It stays open for some time in case you have more client connections to
> the same host coming.
>
> Since v3.0 lws has a pretty sophisticated transparent queuing for multi
> client connection to the same vhost, that works on http/1.1 pipelining if
> that's what you got or h2, broadsiding the connections concurrently on a
> single TLS / tcp "nwsi".
>
>  2.
>>
>>     If I want to send the same request again, seems I need to call
>>     lws_client_connect_via_info() again which creates nwsi and h2_wsi
>>     again (i.e., SSL handshake again), is there a way I can reuse the
>>     previous allocated nwsi and h2_wsi?
>>
>
> If the nwsi is still up, it should use it.
>
> Have a play with:
>
> https://libwebsockets.org/git/libwebsockets/tree/minimal-exa
> mples/http-client/minimal-http-client-multi
>
> this has switches that let you test multiple client connections
> simultaneously or with with staggered delays (to stress the queuing
> algorithm) in h1, h1 with pipelining and h2.  Various combinations of this
> run as part of the CI testing on travis against both a local server and
> libwebsockets.org.
>
> If there are problems coming, talking about how to reproduce them with
> that + whatever hack patch is needed will make it much easier to look at it.
>
> -Andy
>
> Thanks
>> -Xi
>>
>>
>>
>>
>> _______________________________________________
>> Libwebsockets mailing list
>> Libwebsockets at ml.libwebsockets.org
>> https://libwebsockets.org/mailman/listinfo/libwebsockets
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20180822/2540f255/attachment-0002.html>


More information about the Libwebsockets mailing list