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

Andy Green andy at warmcat.com
Fri Jan 31 08:45:37 CET 2020

On 1/31/20 7:28 AM, dev akira wrote:
> 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.

Thanks for the testing.

> 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?

No, I forgot to transfer an asset from the "active connection leader"... 
the "leader" the other guys can queue on keeps a copy of his original 
endpoint so it can be compared with what any new guys want... now the 
leader changes that's also part of what the new leader has to inherit so 
the new leader can be understood as viable.

This should fix it:

diff --git a/lib/core-net/wsi.c b/lib/core-net/wsi.c
index 8535713df..ddf389609 100644
--- a/lib/core-net/wsi.c
+++ b/lib/core-net/wsi.c
@@ -844,6 +844,12 @@ 
_lws_generic_transaction_completed_active_conn(struct lws **_wsi)
         wsi->tls.use_ssl = 0;

+       /* take over his copy of his endpoint as an active connection */
+       wnew->cli_hostname_copy = wsi->cli_hostname_copy;
+       wsi->cli_hostname_copy = NULL;
          * selected queued guy now replaces the original leader on the
          * active client conn list

I updated yesterday's patch in place on master as well.


More information about the Libwebsockets mailing list