[Libwebsockets] Client without protocol name

andy at warmcat.com andy at warmcat.com
Wed May 12 23:19:02 CEST 2021

On May 12, 2021 8:23:28 PM UTC, Mykola Stryebkov <mykola.stryebkov at icloud.com> wrote:
>It it possible to create a client connection to a remote server (with
>lws_client_connect_via_info) without a protocol name?
>Is it enough to just set local_protocol_name field to NULL?

No, that should be the name of the protocol struct instance to bind the connection to on the client side, ie, defines how to wire the connection up to the protocol callback you want to use at the client side.  The protocol name used only on the client side for that is private to the client then, it should not be NULL but anything unique at the client.

You can leave .protocol  NULL to specify the subprotocol list used for negotiation with the server should be omitted.

If the server is under your control, it's always a bad idea to not have an explicit subprotocol name.  You can only offer one of those per vhost, no way to detect if you actually negotiated to use someone else's anonymous protocol on a different server by mistake, and no way to manage subprotocol versioning.


>Thanks in advance.
>>With respect, M.
>Public GnuPG key: 0x01731B47DBD56C0F
>fpr: 0226 54EE C1FF 8636 36EF  2AC9 BCE9 CFC7 9CF4 6747

More information about the Libwebsockets mailing list