[Libwebsockets] Is ws_ping_pong_interval the only way to find out dis-connected clients ?

hanguofu hanguofu at 163.com
Sat Feb 11 15:35:02 CET 2017





At 2017-02-11 04:37:16, "Andy Green" <andy at warmcat.com> wrote:
>
>
>On February 11, 2017 1:21:02 AM GMT+08:00, hanguofu <hanguofu at 163.com> wrote:
>>Hi , there :
>>
>>
>>I would like to maintain  a list of online clients at the server side.
>>( Both of the clients and the server implement LWS library version
>>2.1.0. ) So at the "LWS_CALLBACK_CLOSED" callback of the server , I
>>deleted the dis-connected peer from the list. Unfortunately , sometimes
>>it does not work : the peer dis-connected without server's notice.
>
>What happens when you get that situation?


The disconnected client seems O.K. At least , according to the log file of the
disconnected client , it exits normally with "NOTICE: lws_context_destroy"  
and "LWS_CALLBACK_CLOSED" callback is called --- the logic/program at the
client side functions.
However, the server didnot know the interested client was disconnected , so
it sent messages to the client as usual. After a while , it finally finds out :
the  "LWS_CALLBACK_CLOSED" callback is triggered and the peer is removed from the list.


Of course , the greatest lost is the sent messages , gone with the wind too:(
Is that what you are asking ?



Regards !



Guofu Han






>
>>Is the ping-pong feature the only way out ?
>
>More exactly under some conditions it's only when you try to write to a silently "gone" peer that you can realize he's gone.  The ping / pong stuff will guarantee to provide writes on idle connections at intervals, so lws can know they are gone with a maximum latency and close them.
>
>-Andy
>
>>
>>Regards !
>>
>>
>>Guofu Han



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20170211/ca8223b4/attachment-0002.html>


More information about the Libwebsockets mailing list