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

使用conv模式情况下,客户端连上服务器后,关闭客户端再登录,大概率会导致通讯失败。使用KcpReconnectExampleClient示例很容易出现。 #40

Open
evallili opened this issue Jul 25, 2024 · 4 comments

Comments

@evallili
Copy link

使用conv模式情况下,客户端连上服务器后,关闭客户端再登录,大概率会导致通讯失败。使用KcpReconnectExampleClient示例很容易出现。

@l42111996
Copy link
Owner

把超时时间弄短点,或者在业务层加挥手协议,kcp是通过心跳机制检测链接是否存活的,如果在心跳时间内客户端关闭再登录,需要等心跳超时过了以后同样的conv才能链接上

@evallili
Copy link
Author

image
是否可以在接收数据这里,如果remoteAddress改变了,就关闭旧通道,使用新的通道。

@l42111996
Copy link
Owner

image 是否可以在接收数据这里,如果remoteAddress改变了,就关闭旧通道,使用新的通道。

不可行,有一种需求是从4G切换到wifi 要保证网络链接不断开,这种情况下需要remoteAddress变了但是conv没变连接不断开。

@l42111996
Copy link
Owner

想了这个问题有一种解法:如果remoteAddress变了,conv没变,收到的包sn为0(消息的第一个包),就用把老的链接关掉,用新的链接

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

No branches or pull requests

2 participants