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

Unsubscribe on agent disconnection #15

Closed
wants to merge 2 commits into from

Conversation

bensheldon
Copy link

This commit fixes #14 by tracking subscriptions in the Agent model and unsubscribing from those channels on disconnection.

BUT, it now presents another issue: once a channel's subscribers drops to zero, subsequent new subscribers to that channel are no longer able to send messages. I'm not sure if that's an issue with InMemoryMQ or somewhere else, but I thought I'd open the pull request to see if you had any ideas.

@aaronblohowiak
Copy link
Owner

Tracking the subscriptions in Agent makes some sense, but we'd also need to track unsubs there to keep it coherent. I will think more about this later tonight, but my current thoughts are that this should be stored in the SubscriptionManager.. either way, your unsub agent on disconnect does need to notify the subscriptionmanager that the agent should be considered dead.

For the channel's subscribers dropping to zero, I need to add a delete this.subscriptions[chan] inside the SubscriptionManager.prototype.unsubscribe function on the condition that the subscription count drops to zero -- it is unsubscribing from the mq (which is correct) but it did not perform the final clean-up. Good catch.

These issues are coming up because of the recent re-factor to use SockJS -- socket.io would allow us to send messages to disconnected clients without complaint (which I consider an anti-feature.)

Sorry for the instability, I will add more tests to cover these cases soon.

@bensheldon
Copy link
Author

This PR seems pretty stale. Closing it out.

@bensheldon bensheldon closed this Jun 29, 2015
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

Successfully merging this pull request may close these issues.

Disconnected agent causes invalid_state_err
2 participants