-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
fix: don't use broker id from client object #110
Conversation
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.
Could you add a test that covers this?
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.
After double checking this and also https://github.com/moscajs/aedes-persistence-mongodb/blob/master/persistence.js#L585
I remember that the reason why we use client brokerId is that in case of a cluster usage the client brokerId can be different from this.broker.id. So this is wrong I'm sorry, we should detect the reason why the brokerId is not set on your case
I have a feel that the test you added would pass even without the change on persistence? There was already a test that covers the put/del/getWill here: https://github.com/moscajs/aedes-persistence/blob/main/abstract.js#L1458
@robertsLando thanks for the feedback. The test does fail without my change, because I'm not setting the broker id explicitly in my test so that causes it to fail. The test you referenced is explicitly setting the brokerId before calling I can investigate my use case further to determine where the issue is. I would expect all the methods |
So after investigating a little further, I think the issue I'm trying to solve is more related to how aedes and the persistence work. What I was trying to solve, was when a client connects to aedes with a LWT, it is stored in redis. However, if that client disconnects gracefully then we don't need to send the will message. But that also means that the key is never cleaned up from redis. So based on this code in aedes it may be an issue with aedes, or just how it's supposed to function. |
By checking that code the issue seems to be on aedes, when the will is present we should always delete it after the disconnection |
I'm going to close this then. I put up a PR in aedes with the fix |
The
delWill
method is accessing the brokerId from client, which is undefined and therefore causing the key to not be deleted. This updatesdelWill
to get the broker id fromthis.broker.id
similar to how getWill is doing it.