[Libwebsockets] RE: callback_reasons for browser disconnect

Andy Green andy at warmcat.com
Wed Apr 8 05:31:01 CEST 2015



On 8 April 2015 10:30:37 GMT+08:00, Jeffrey Zhao <chunyong.zhao at qq.com> wrote:
>Dear Andy
>Seems LWS_CALLBACK_CLOSED callback meet my basic requirements.‍
>But from my understanding, since websocket is based on TCP protocol,
>which has timeout mechanism if network connectivity is lost.

It's optional... I believe we turn it on.

>I want to confirm with whether there is LWS_CALLBACK_CLOSED callback if
>low layer TCP connection is lost.‍

You can check it by, eg, connecting and pulling one of the network cables.  Either it'll notice after a while or it won't.

>Regarding PING/PONG suggestion, I need to consider how to implement at
>client side, since it is a browser, which has only Javascript language.

PING and PONG are part of websockets.  I think if you sent a PING to the client he ought to send a PONG by himself.

-Andy

>
>Thank you very much.
>
>
>
>
>
>
>
>
>------------------ 原始邮件 ------------------
>发件人: "Andy Green";<andy at warmcat.com>;
>发送时间: 2015年4月7日(星期二) 晚上10:48
>收件人: "Jeffrey Zhao"<chunyong.zhao at qq.com>;
>"libwebsockets at ml.libwebsockets."<libwebsockets at ml.libwebsockets.org>; 
>
>主题: Re: [Libwebsockets] callback_reasons for browser disconnect
>
>
>
>
>
>On 7 April 2015 22:27:04 GMT+08:00, Jeffrey Zhao <chunyong.zhao at qq.com>
>wrote:
>>Dear Sir
>>I am wondering what the callback reason type is for browser disconnect
>>event.
>>
>>
>>I have tried LWS_CALLBACK_WSI_DESTROY, but found event safari process
>>is killed, there is no callback triggered.‍
>
>You can't rely on getting a disconnect indication.
>
>For example an intermediate router network cable falls out, there will
>be no indication until you try to send something to the remote peer. 
>Or your Mac catches fire.
>
>So you need to implement something like PING / PONG at intervals to
>confirm the remote peer is still responsive to cover all cases.
>
>-Andy
>
>>
>>
>>
>>Thanks.
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Libwebsockets mailing list
>>Libwebsockets at ml.libwebsockets.org
>>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list