Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gateway模型下,如果服务器一直主动push消息给客户端,客户端直接拔掉网线,心跳机制失效 #21

Closed
liujian883 opened this issue Apr 9, 2015 · 2 comments
Labels

Comments

@liujian883
Copy link

我们采用的是gateway/worker模型,在我们的工作场景中,客户端会每隔4S,发送心跳给服务器,服务器不会主动发送心跳消息。
使用的心跳机制同下:
$gateway = new Gateway("Websocket://0.0.0.0:8585");
$gateway->pingInterval = 4;
$gateway->pingNotResponseLimit = 2;
$gateway->pingData = '';
虽然服务器不会发送心跳消息给客户端,但是,服务器是需要不断的PUSH正常的消息给服务器。
假如在服务器不断PUSH的过程中,客户端直接拔掉网线,我们发现,服务器不能识别出客户端已经断网,心跳机制失效。
但是,如果我们不让服务器PUSH正常消息的话,只要客户端拔掉网线,8s过后,服务器能够识别到客户端断网。
请问这是什么原因造成的呢?谢谢!

@walkor
Copy link
Owner

walkor commented Apr 10, 2015

在服务器不断PUSH的过程中,客户端直接拔掉网线服务器不能识别出客户端已经断网

其实这里服务端已经发现客户端没有发心跳超过了pingNotResponseLimit限制,已经调用了$connection->close();,但是$connection->close();有一个机制,如果当前链接$connection还有数据未发送,则必须等待数据发送完毕才真正断开,才会出发onClose。但是由于客户端网线被拔,所以数据一直发送超时,TCP层面会一直重试,直到一定时间(依赖系统内核配置,一般是10分钟以上)TCP层面才会断开,才会出发onClose。

这个问题将会在本周内修复,谢谢反馈。

@walkor
Copy link
Owner

walkor commented Apr 11, 2015

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants