[Libwebsockets] Do we have plan to support web socket over http2 client on libwebsockets.

Andy Green andy at warmcat.com
Thu Sep 20 09:10:20 CEST 2018



On 20/09/2018 14:53, zhang guojun wrote:
> Andy, you reply really quick. Thanks a lot.
> See the inline comments.

Your email client seems to be pretty messed up.

>> On Sep 19, 2018, at 11:08 PM, Andy Green <andy at warmcat.com> wrote:
>>
>>
>>
>> On September 20, 2018 1:51:52 PM GMT+08:00, zhang guojun <guojunzhang1981 at gmail.com> wrote:
>>> Thanks Andy, I learn a lot from your reply.
>>> I agree with your answer on the case I said. In that case H2 may not
>>> helpful.
>>>
>>> Let me introduce another case, for specific Client which have multiple
>>> applications and trying to push data into server at almost same time,
>>> but one application send a huge data to server, say 5M Bytes size,
>>> another application, a latency sensitive application, send a small size
>>> request to server, it expect a immediate response from server.
>>
>> This sounds more like a real-world problem.
>>
>> But if you open two separate h1 ws connections back to the server, there's no relationship between the connection sending a 5MB message and the time-sensitive smaller message on a different tcp connection, right?  Traffic from both will be interleaved and the small message will appear quickly.
>>
>> If the two logical ws messages are actually different logical ws subprotocols, you'd normally do that as two separate ws connections anyway.
> [GZ]: Yeah, this is a real-world problem. And I agree two or multiple connections could solve my problem. But actually there are thousands and thousands of such clients, each client have more than ten of such applications, if I create multiple connections, which will increase much of pressure of the server :-(.

It's certainly neater to do it one tcp connection.  But it seems this is 
proprietary software you are making... you expect to turn a profit on 
it... you can afford a bigger server / more servers... or pay someone to 
implement ws-over-h2... none of those considerations are my problem.

Solve it with two h1 + ws connections...

>>> So H2 should solve this scenario in my case, right?
>>
>> Yeah... it will be the same or worse (depending on what else the bundle is shared with) than doing it as two separate ws tcp connections.
>>
>> With multiple client http connection binding, it happens automatically just by opening the individual client connections without knowledge of each other... lws sees they're going to the same host, that one is already connected or connecting there and binds them together automaically.
>>
>> https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/http-client/minimal-http-client-multi
>>
>> When eventually client ws-over-h2 support appears it will likely work the same way.  So you should just open one ws connection each for big messages using one subprotocol (sending a smaller ws fragment on each WRITABLE) and another for urgent messages using another subprotocol.  That will solve your problem today on h1 and probably be compatible to automatically use client ws-over-h2 when it appears.
> [GZ]: it’s a great feature, good to know it. I definitely haven’t access libwebsockets for a long time.
> 
> [GZ]: I personally like websocket more than H2 in C/S mode, I though it will inherit MUX in ws-over-h2, looks like it doesn’t. I’m not sure if you have any chance do something before it come to RFC. :-)

Eh... "inherit mux... looks like it doesn't..."...

Two h1 + ws tcp connections solves this as told before.

So when I write:

 >>> So H2 should solve this scenario in my case, right?
 >>
 >> Yeah... it will be the same or worse (depending on what else the 
bundle is shared with) than doing it as two separate ws tcp connections.

It is telling you h2 will be the same as something that solves it, or 
possibly worse because it's not defined what other streams are active on 
the same h2 bundle.

I don't know what "inheriting mux" means to you but if your 5MB connection:

 > open one ws connection each for big messages using one subprotocol 
(sending a smaller ws fragment on each WRITABLE)

ie, doesn't moronically send all 5MB at once when h2 tells it that it 
can talk, violating the tx credit rules and recreating the same problem 
you have on h1, and the h2 bundle is otherwise idle, then yes, 
ws-over-h2, on one connection, will solve it similarly to two h1 ws 
connections.

But client ws-over-h2 doesn't exist.  So solve it for now with 2x h1 
connections.

-Andy


More information about the Libwebsockets mailing list