[Libwebsockets] Is there a way to reuse a lws_context without destroying it

Andy Green andy at warmcat.com
Wed Jun 14 09:56:48 CEST 2017

On 06/14/2017 02:35 PM, Ash 20001 wrote:
> Is there a way to call lws_create_context just once for program lifetime 
> as a client, and use that context for many connections (ie. connect to a 
> server, disconnect, repeat)? I have tried but it doesn't seem to work on 
> the second connection.

Yes it should be fine.

Libwebsockets-test-client does exactly this in its normal operation.

What exactly happens (and does it happen on lws master?)

> The reason I ask is because I am having SSL issues with other threads 
> that I have no control over in a process which use ssl functions in 
> CURL. lws_destroy_context globally destructs SSL state and causes 
> issues.  My openssl version is rather old 0.9.8 and cannot be changed.

If another thread in the process is destroying openssl processwide it 
will trash any thread's ability to use openssl.


> Thanks!
> (Sorry if I sent two emails, not sure if the first one went through 
> because I was trying to subscribe to the mailing list).
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list