[Libwebsockets] Returning wrong protocol number when initialising the context

Gilles Printemps gprintemps at gmail.com
Mon Nov 18 14:00:46 CET 2019


Hi Andy,
My shared library was already compiled with the flag you mentioned:
   cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DLWS_WITHOUT_TESTAPPS=1

I've discovered the issue regarding the number of protocols thanks to the
logs
[2019/11/18 10:55:02:1782] I: Initial logging level 8
[2019/11/18 10:55:02:1782] I: Libwebsockets version: 3.2.0 v3.2.0
[2019/11/18 10:55:02:1782] I: IPV6 not compiled in
[2019/11/18 10:55:02:1782] I:  LWS_DEF_HEADER_LEN    : 4096
[2019/11/18 10:55:02:1782] I:  LWS_MAX_PROTOCOLS     : 5
[2019/11/18 10:55:02:1782] I:  LWS_MAX_SMP           : 1
[2019/11/18 10:55:02:1782] I:  sizeof (*info)        : 648
[2019/11/18 10:55:02:1782] I:  SYSTEM_RANDOM_FILEPATH: '/dev/urandom'
[2019/11/18 10:55:02:1782] I:  HTTP2 support         : available
[2019/11/18 10:55:02:1782] I: context created
[2019/11/18 10:55:02:1782] I: Using event loop: poll
[2019/11/18 10:55:02:1783] I: Default ALPN advertisment: h2,http/1.1
[2019/11/18 10:55:02:1783] I:  default timeout (secs): 20
[2019/11/18 10:55:02:1783] I:  Threads: 1 each 1024 fds
[2019/11/18 10:55:02:1783] I:  mem: context:          5144 B (1048 ctx + (1
thr x 4096))
[2019/11/18 10:55:02:1783] I:  mem: http hdr size:   (4096 + 976), max
count 1024
[2019/11/18 10:55:02:1783] I:  mem: pollfd map:       8192 B
[2019/11/18 10:55:02:1783] I:  mem: platform fd map:  8192 B
[2019/11/18 10:55:02:1783] I:  Compiled with OpenSSL support
[2019/11/18 10:55:02:1783] I:  SSL disabled: no
LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT
[2019/11/18 10:55:02:1783] I: Creating Vhost 'default' port 9000, 1
protocols, IPv6 off
[2019/11/18 10:55:02:1784] I: lws_vhost_bind_wsi: vh default:
count_bound_wsi 1
[2019/11/18 10:55:02:1784] I:  Listening on port 9000
[2019/11/18 10:55:02:1784] I:  mem: per-conn:          696 bytes + protocol
rx buf
[2019/11/18 10:55:02:1784] I:  canonical_hostname = Corellia
[2019/11/18 10:55:02:1784] I: lws_plat_drop_app_privileges: not changing
group
[2019/11/18 10:55:02:1784] I: lws_plat_drop_app_privileges: not changing
user
[2019/11/18 10:55:02:1784] I: lws_cancel_service
[2019/11/18 10:55:02:1785] I: lws_context_destroy: ctx 0xefa150
[2019/11/18 10:55:02:1785] I: lws_destroy_event_pipe
[2019/11/18 10:55:02:1786] I: __lws_close_free_wsi: 0xefabc0: caller: ctx
destroy
[2019/11/18 10:55:02:1786] I: lws_vhost_unbind_wsi: vh default:
count_bound_wsi 0
[2019/11/18 10:55:02:1787] I: lws_context_destroy2: ctx 0xefa150
[2019/11/18 10:55:02:1787] I: __lws_vhost_destroy2: 0xefa830
[2019/11/18 10:55:02:1787] I:   __lws_vhost_destroy2: Freeing vhost 0xefa830
[2019/11/18 10:55:02:1788] I: lws_context_destroy3: ctx 0xefa150 freed

Is there a way to get more details on the ghost creation?


On Mon, Nov 18, 2019 at 12:03 PM Andy Green <andy at warmcat.com> wrote:

>
>
> On 11/18/19 10:55 AM, Gilles Printemps wrote:
> > Hi,
> > When I'm executing the following example (using libwebsockets 3.2.0), I
> > got the following output through the logs
> > *"Creating Vhost 'default' port 9000, 5 protocols, IPv6 off"*
> > Can someone explain why "5 protocols" are returned?
>
> If you're curious about what's going on in lws you can increase the log
> verbosity, it reports what vhosts it's creating at startup using INFO
> log level.
>
> Select -DCMAKE_BUILD_TYPE=DEBUG at cmake and recook lws, then enable
> LLL_INFO logging.
>
> -Andy
>
> > BR
> >
> >
> > #include <vector>
> > #include <libwebsockets.h>
> >
> > static int WSCallback(struct lws *wsi,enum lws_callback_reasons
> > reason,void *session,void *data,size_t len) {}
> >
> > int main(int argc, char* argv[]) {
> >    lws_set_log_level(12,NULL);
> >    std::vector<lws_protocols> _protocols;
> >    _protocols.push_back({"ZWave",WSCallback,128,128,0,nullptr});
> >
> >    struct lws_context *context=NULL;
> >    struct lws_context_creation_info info;
> >    memset(&info, 0, sizeof info);
> >    info.port = 9000;
> >    info.protocols = _protocols.data();
> >    info.gid = -1;
> >    info.uid = -1;
> >    info.options = 0;
> >    context=lws_create_context(&info);
> >
> >    if (context==NULL) {
> >      printf("libwebsocket init failed\n");
> >      return -1;
> >    }
> >
> >    lws_context_destroy(context);
> > }
> >
> > _______________________________________________
> > 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/20191118/02d90a44/attachment.htm>


More information about the Libwebsockets mailing list