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

服务端主动关闭Dispose() 问题 #298

Open
bigorange1900 opened this issue Sep 17, 2020 · 2 comments
Open

服务端主动关闭Dispose() 问题 #298

bigorange1900 opened this issue Sep 17, 2020 · 2 comments

Comments

@bigorange1900
Copy link

1:启动服务
2:客户端websocket连接
3:发送数据给服务端,服务端收到
4:服务端主动执行关闭Dispose()后,客户端并没有任何断线反应,然后客户端发送数据,服务端还是收得到,如果直接关闭服务端进程,则客户端马上就反应掉线,同时自动连接就会连接不上
5:如果把客户端浏览器重新刷新一下,然后就会连接不上服务端

目前问题主要体现在,服务端主动执行关闭(非进程关闭),客户端没刷新的前提下,还是可以发数据到服务端,怎么解决?

@bigorange1900
Copy link
Author

难道要主动执行Dispose()之前,把所有连接客户端都要Close一下么?但这又有个问题,因为这个时候可能还没有执行Dispose()的时候,有些客户端就自动连接请求上来了

@bigorange1900
Copy link
Author

尝试了一下,服务先主动执行Dispose(),,然后再循环关闭所有连接客户端dicSockets.Values.ToList().ForEach(s => s.Close()); 后能达到想要的效果,但总觉得有点怪怪的

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

1 participant