-
Notifications
You must be signed in to change notification settings - Fork 76
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
没有服务器响应超时的心跳 #9
Comments
感谢支持。你可以再看一下IdleStateHandler中的超时参数。在客户端IdleStateHandler中,设置了写超时5s,意思是客户端5s内没发送消息,会触发userEventTriggered函数,在这个函数中我发送心跳数据。与接收服务端数据没关系 |
对的,服务端和客户端分开的。按照你的意思,你不想让客户端发心跳的话,可以不设置写超时,设置读超时,表示几秒没收到服务端的消息后,触发userEventTriggered函数 |
也可以 你客户端5s内0,有消息发给服务端,就不会触发userEventTriggered函数,这样明白了吗 |
恩 明白了,非常感谢,我在你代码的基础上加了个客户端获取消息超时的心跳,符合我业务的需求了,再次感谢大佬 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
作者你好,非常感谢你的demo思路,我在运行过程中发现没有服务器对心跳响应超时的部分代码,我自己加了一下,代码如下,我设置了当IdleStateHandler的读写超时时间分别是10秒和5秒
然后在接收消息的地方对心跳消息进行过滤,代码如下
这样当我的手机出现网络连接超时,发送心跳之后在对应超时时间没有收到服务端的心跳回复时,会触发重新连接,整套流程我测了一下没有大的毛病;但是我发现,即使我的业务正常,即正常收到服务器回复的业务数据时(没有超过读超时时间),userEventTriggered的写超时被回调,发送了心跳数据给服务端,我不明白这是netty正常的工作流程,还是我哪里封装错了?还望作者给予指导,谢谢
The text was updated successfully, but these errors were encountered: