[Libwebsockets] Re-connection logic for libwebsockets

Andy Green andy at warmcat.com
Tue Dec 8 04:52:49 CET 2015

On December 8, 2015 11:18:47 AM GMT+08:00, Hemant Kumar <hkumar at arubanetworks.com> wrote:
>I have a working libwebsocket client server and I am trying to
>implement reconnection logic between the two entities.
>Basically, when connectivity to server is down for some reason, client
>keeps on trying libwebsocket_connect with same
>parameters as used for the initial successful connection establishment.
>I do see , client making repeated tries but every time connection
>attempt fails , although server is UP on another end.
>For every failed try, I see libwebsocket_conext_destrory being also
>called, wondering if I am missing anything to clean
>the old context for the re-establishment of connection.

Need more info about where (and / or why) it fails.

However a common mistake is to not memset the info struct to zero before filling it in.

Another way to get 'memory' between sessions is via your protocols struct, try copying it each time into another protocols struct and give that one to lws_client_connect.


>Please advise.
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

More information about the Libwebsockets mailing list