-
Notifications
You must be signed in to change notification settings - Fork 212
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
Handle expired clients in server.loadClients(). #341
Conversation
Pull Request Test Coverage Report for Build 7128618616
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, and a good solution. For me, it's approved! Thank you for finding this @werbenhu!
I think this change make the logic become too difficult. The loaded client should be invoke the With this commit, there will get some issues.
|
@x20080406 If the client has already expired, it would be reasonable to clear its Now that 'cl' has been deprecated, and you have obtained all the necessary information from it, what is the significance of keeping it continued in 'Clients'? Calling 'stop()' can also resolve the issue. However, it follows the same final processing logic, and it adds two redundant operations: adding the client to 'Clients' and then removing it. |
Released in v2.4.3 |
@x20080406 @werbenhu @mochi-co s.NewClient will start the WriteLoop in a Go routine for non-inline clients: Lines 231 to 239 in 624dde0
This will only stop if cl.Stop or cl.State.cancelOpen is called. |
@thedevop I found this too, and I will submit a new pull request to fix it. |
I encountered a problem similar to #339 . If the broker is forcefully shut down, and clients have the clean flag set, after restarting the broker and calling loadClients(), these expired clients will be retained indefinitely if the client is no longer connected.
It is necessary to handle expired clients in server.loadClients(). Call OnDisconnect() to trigger the hook for clearing persistent clients. Also, if a client has expired, there is no need to retain this client in server.Clients.