[Libwebsockets] RE: callback_reasons for browser disconnect

Jeffrey Zhao chunyong.zhao at qq.com
Wed Apr 8 04:30:37 CEST 2015

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.
I want to confirm with whether there is LWS_CALLBACK_CLOSED callback if low layer TCP connection is lost.‍

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

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
>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.


>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20150408/1ee3fa76/attachment-0001.html>

More information about the Libwebsockets mailing list