[Libwebsockets] Confusion about contexts/vhosts/protocols
andy at warmcat.com
Thu Jun 20 14:43:01 CEST 2019
On 6/20/19 12:36 PM, Zevv wrote:
> Hi all,
> I started looking into libwebsockets today to see if it could replace a
> lot of custom code in one of our products. I'm trying to build a simple
It's not really that simple.
> test app which should perform an outgoing HTTPS request and at the same
> time accept generic TCP clients on listening port.
> Code is at http://paste.ubuntu.com/p/QYwnmVw77h/
> I have created a context with EXPLICIT_VHOST, and created two vhosts:
You only really need the one vhost set up to do the serving, the client
can piggyback on that. Client mainly care about the vhost because
that's where they get their tls context from.
> one for the server and one for the client context. The server vhost
> has the _ADOPT_APPLY_LISTEN_ACCEPT_CONFIG option and listen_accept_*
> fields set.
> I now find this kind-of-works, but the behaviour depends on the order of my
I don't really have time to reproduce and debug your situation.
> protocols in the lws_protocols passed to lws_create_context(): if the
> "http-client" protocol is put first, the server vhost will not handle the
> connection with the "raw-test" callback, even though that is explictily
> configured in listen_accept_protocol.
This isn't surprising if the listen_accept_protocol stuff is NULL (see
below) but if you think it isn't, you should probably trace what's
happening with that in lws.
> Where in the documentation could I find a good description of whis
There are docs as you found in the headers, eg
/**< (VH) All connections to this vhost / port are bound to the
* role and protocol given in .listen_accept_role /
* If those explicit user-controlled names are NULL, for backwards-
* compatibility the connection is bound to "raw-skt" role, and in order
* of priority: 1) the vh protocol with a pvo named "raw", 2) the vh
* protocol with a pvo named "default", or 3) protocols.
* It's much preferred to specify the role + protocol using the
* .listen_accept_role and .listen_accept_protocol in the info struct.
Patches welcome for more good docs, or fixes.
> Thank you!
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets