[Libwebsockets] How to properly handle LWS_CALLBACK_CLIENT_CONNECTION_ERROR?

Brice Hamon brice at ydotm.com
Wed Jun 27 16:42:57 CEST 2018


That's interesting.

What I do is I store in my class the lws_client_connect_info structure
previously filled  with the my connection info.

And when I lose the connection, periodically I
call lws_client_connect_via_info() with that same cli when I want to
reconnect and that works.

On Wed, Jun 27, 2018 at 10:24 AM, Alfred Sawaya <alfred at huji.fr> wrote:

> Hello Duane,
>
> A memory leak has been corrected in the v3.0 branch. It happens exactly in
> your case (when a websocket fails to upgrade), can you try this version ?
> https://github.com/warmcat/libwebsockets/commit/
> 3f7ffeddac34e85c5c000c687dbdbd204e74b376
>
> Thank you,
> Alfred
>
> Le mer. 27 juin 2018 à 16:18, Duane Butler <Duane.Butler at calix.com> a
> écrit :
>
>> Using libwebsockets version 2.4.1
>>
>>
>>
>> My application creates a context (lws_create_context) and a socket
>> (lws_client_connect_via_info).
>>
>>
>>
>> When the connection fails (or is closed by the other end), I want to
>> retry again after a random timeout.
>>
>>
>>
>> What is the proper way to code this?
>>
>>
>>
>> Currently, I’ve tried the following:
>>
>>    - Call lws_client_connection_via_info again (reusing existing context)
>>    - Call lws_context_destroy and start over
>>
>>
>>
>> These methods work, but result in a memory leak. I have a situation where
>> I cannot connect for a couple days and the memory leak becomes significant.
>>
>>
>>
>> Thanks in advance for the help.
>>
>>
>>
>> Duane.
>>
>>
>> _______________________________________________
>> Libwebsockets mailing list
>> Libwebsockets at ml.libwebsockets.org
>> https://libwebsockets.org/mailman/listinfo/libwebsockets
>>
> --
> Cordialement,
> Alfred Sawaya
>
> _______________________________________________
> 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/20180627/8d3b5460/attachment-0002.html>


More information about the Libwebsockets mailing list