如何检测长连接客户端是否掉线

138 views
Skip to first unread message

calvin.zhang

unread,
Aug 18, 2016, 5:11:13 AM8/18/16
to openresty
hi,all

新手最近在用iresty.websocket搭建长连接推送,有以下困惑希望大家能给点意见

1、设置 lua_socket_keepalive_timeout 60s;  客户端超时了,日志里头打印出了
2016/08/18 16:11:52 [info] 17455#0: *766 client timed out (110: Connection timed out) while waiting for request
但是长连接并不会断开,客户端发送消息依然能被服务器接收,通信正常。
长连接超时有回调函数吗?


2、日志打印的时候为什么一条日志会打印多条?

YuanSheng Wang

unread,
Aug 19, 2016, 8:24:31 AM8/19/16
to open...@googlegroups.com

2016-08-18 17:11 GMT+08:00 calvin.zhang <ihuei...@gmail.com>:
hi,all

新手最近在用iresty.websocket搭建长连接推送,有以下困惑希望大家能给点意见

你这里是不是写错了,应该是 resty.websocket ,没有前面的字母 i 
 

1、设置 lua_socket_keepalive_timeout 60s;  客户端超时了,日志里头打印出了
2016/08/18 16:11:52 [info] 17455#0: *766 client timed out (110: Connection timed out) while waiting for request

客户端超时,错误信息怎么会是 Connection timed out ?不懂了
 
但是长连接并不会断开,客户端发送消息依然能被服务器接收,通信正常。

对于创建好的长连接,recieve 一方捕获到超时,是可以忽略进入下一次 recieve 动作,链路本身还是正常的。
 
长连接超时有回调函数吗?


2、日志打印的时候为什么一条日志会打印多条?

可以尝试关掉 lua cosocket 自身的日志,有可能是这个在干扰你。


--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty+subscribe@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+unsubscribe@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html



--

YuanSheng Wang
---------------------------------------
OpenResty lover ^_^

DeJiang Zhu

unread,
Aug 20, 2016, 10:26:40 AM8/20/16
to open...@googlegroups.com
Helllo

最保险的是自己实现应用层的心跳,心跳超时即可认为连接坏了

--
Reply all
Reply to author
Forward
0 new messages