[Libwebsockets] How to properly handle LWS_CALLBACK_CLIENT_CONNECTION_ERROR?

Duane Butler Duane.Butler at calix.com
Wed Jun 27 17:20:20 CEST 2018


Thanks Alfred and Brice for the quick replies!

Brice,

I think you’re saying I should save/reuse my “struct lws_client_connect_info” on subsequence calls to lws_client_connect_via_info()?

Previously, I was re-initializing that struct every time.

I just tried it, but it doesn’t fix the memory leak.

Please let me know if I misunderstood.

Thanks.

Duane.

From: normandviking at gmail.com <normandviking at gmail.com> On Behalf Of Brice Hamon
Sent: Wednesday, June 27, 2018 9:43 AM
To: Alfred Sawaya <alfred at huji.fr>
Cc: Duane Butler <Duane.Butler at calix.com>; libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] How to properly handle LWS_CALLBACK_CLIENT_CONNECTION_ERROR?

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<mailto: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<mailto: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<mailto:Libwebsockets at ml.libwebsockets.org>
https://libwebsockets.org/mailman/listinfo/libwebsockets
--
Cordialement,
Alfred Sawaya

_______________________________________________
Libwebsockets mailing list
Libwebsockets at ml.libwebsockets.org<mailto: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/ea77d9f5/attachment-0002.html>


More information about the Libwebsockets mailing list