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

Andy Green andy at warmcat.com
Wed Jun 14 09:29:44 CEST 2017

On June 14, 2017 2:35:24 PM GMT+08:00, Ash 20001 <ash20001 at hotmail.com> 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.

Yeah.... we have seen it before.  Later openssl fixed it.

It will trash openssl for the whole process.  Is that why you can't get a second client connection in lws?


>(Sorry if I sent two emails, not sure if the first one went through
>because I was trying to subscribe to the mailing list).

More information about the Libwebsockets mailing list