[Libwebsockets] v2.0 crashes
andrejs.hanins at ubnt.com
Fri May 13 11:36:04 CEST 2016
On 05/12/2016 10:01 PM, Andy Green wrote:
>> Well, still bad. With current master I can establish client connection
>> only once. After it is disconnected I try to establish it again, but
>> never get any callback back.
>> I will investigate tomorrow in more details. Just to let you know - it
>> was absolutely rock solid with 1.7.5, never had any single problem with
> Well, v2.0 test client has no problems making multiple connections.
> V2.0 is v1.7 with some patches.
> There's nothing I can do about 'bad', 'crash', except wonder about the code I can't see.
I figured it out why reconnects didn't work for me - I was passing two protocols for vhost creation,
as a result failed connection attempts were notified by LWS_CALLBACK_CLIENT_CONNECTION_ERROR
for the _first_ protocol (that is Http, array index 0), but my code was expecting to get all WS-related
callbacks from the _second_ protocol (array index 1). After I removed Http protocol from the vhost
creation everything started to work fine and no more crashes. So patch is good, thank you Andy!
But I noticed, that SSL_library_init is called twice - first from lws_context_init_ssl_library when I create a
ctx, then from lws_context_init_client_ssl when I call lws_init_vhost_client_ssl.
If I remove LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT from ctx creation, then something breaks
internally, incoming/outgoing connections don't work any more and I get the following logs:
LWS: forbidding on uri sanitation
LWS: error on reading from skt : 131
LWS: SSL connect error 336031996: error:140770FC:lib(20):func(119):reason(252)
So it looks like in order for the SSL to work it needs to be initialized in ctx, but then it is
initialized again due to lws_init_vhost_client_ssl. It doesn't look to be causing any
problems, but initializing SSL more than once doesn't look right to me.
More information about the Libwebsockets