[Libwebsockets] Clean Reconnect not working
andy at warmcat.com
Sun Apr 12 02:27:45 CEST 2015
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.
>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:
>>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
>>prior to the Network connection being live. Our connection
>>can be sporadic, hence the need for automatic connection and reconnect
>>Once it’s connected everything appears to work well, it seems to
>>survive one or two disconnects, I have a LWS_CALLBACK_CLOSED case
>>destorys the libwebsocket context and resets some state variables,
>>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,
>>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.
>>Libwebsockets mailing list
>>Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets