fix: memory leak in connected clients counter #979
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pr is related to the #928
The made fix didn't decrease connectedClients counter, which lead to incorrect amount of clients provided by broker.
One more issue is related to constant increase of subscriptions. My broker has a lot of unique clients per day with short keepAliveTimeout and frequent reconnection and subscription rate. I suspect that the problem is in the authorizeSubscribe method which can be async. This may lead to subscription for closed clients. In this case broker will never unsub them.
Unfortunately, I am limited in experiments on production to prove my idea, but the proposed fix seems reasonable and harmless to me.