[Libwebsockets] Clean Reconnect not working

Andy Green andy at warmcat.com
Thu Apr 9 02:51:43 CEST 2015



On 8 April 2015 22:59:06 GMT+08:00, Deric Panet-Raymond <dpraymond at satcomdirect.com> wrote:
>Hi,
>
>I am trying to design a reconnect sequence using libwebsockets for an
>application and I’m encountering an issue where it seems like the
>callbacks registered by the protocol aren’t being executed after a
>reconnect.  My current sequence has moved the connection to a function
>called open_connection where I create a libwebsocket context and
>perform the connect in a loop as the application will most likely start
>prior to the Network connection being live.  Our connection environment
>can be sporadic, hence the need for automatic connection and reconnect
>after disconnect.
>
>Once it’s connected everything appears to work well, it seems to
>survive one or two disconnects, I have a LWS_CALLBACK_CLOSED case which
>destorys the libwebsocket context and resets some state variables, then
>calls open_connection again.
>
>Can you think of something I might be missing that would cause the
>open_connection to fail after a couple of connect/disconnect cycles, is
>there a cleaner way to implement the reconnect?

Actually the test client heavily tests this... he gives each connection a small random 'lifetime' after which he closes and reconnects.

So I think it's probably okay in lws in general.

I think you need to turn up the debug loglevel and find out what the last thing happening on the last reconnect is.

-Andy

>Thanks,
>
>Deric Panet-Raymond
>x8017
>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list