[Libwebsockets] Clean Reconnect not working

Deric Panet-Raymond dpraymond at satcomdirect.com
Mon Apr 13 16:17:02 CEST 2015


Thanks Andy,


This does look like a similar problem, I¹ll give it a spin and see if it
resolve my issue!

Deric.


On 4/12/15, 10:34 AM, "Andy Green" <andy at warmcat.com> wrote:

>
>
>On 12 April 2015 02:11:10 GMT+08:00, Deric Panet-Raymond
><dpraymond at satcomdirect.com> wrote:
>>The problem is apparently when a TCP connection drops I'm not getting
>>notified,  I tried turning on KeepALive but nothing seems to happen.
>>My application enters a death spiral where it spins at 100% CPU usage
>>in the service_context loop.  The sequence is pull connection, app
>>attempts to write data, the write is apparently successful even though
>>the connection has been physically removed and then it goes back and
>>spins in service_connection.
>
>This sounds a lot like the case someone else just tracked down to
>timeouts when you had pending partial send data buffered continously
>trying to flush the data to a dead connection... please try current git
>HEAD, where closes specifically from timeout are now unconditional.
>
>When it tries to close with buffered partial send data, it sets a timeout
>for clearing that automatically.  So this should so something for your
>problem hopefully.
>
>-Andy
>
>>
>>I'm kind of at a loss at this point.  My app is single threaded, I'm
>>probably going to implement some sort of timer and if I dont receive a
>>packet back from the server I'll tear down the connection and restart.
>>
>>
>>Sent from my LG Mobile
>>
>>
>>------ Original message------
>>
>>From: Andy Green
>>
>>Date: Sat, Apr 11, 2015 2:04 PM
>>
>>To: Deric Panet-Raymond;libwebsockets at ml.libwebsockets.org;
>>
>>Subject:Re: [Libwebsockets] Clean Reconnect not working
>>
>>
>>
>>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