Open bensheldon opened 13 years ago
Tracking this down, it looks like the issue is that when agents disconnect, they are only removed from the list of agents (Agent.remove()), not unsubscribed from the channels. Thus when a new message is pushed out to a channel, it tries to send it to agents who have already disconnected. I tried wrapping SubscriptionManager.received in an error handler, at it "solved" the problem:
proto.received = function(chan, message){
var ss = this.subscriptions[chan];
if(ss){
for(var agentId in ss.agents){
try {
// attempt to send the message
ss.agents[agentId].send(message);
}catch(err){
if (err = 'invalid_state_err') {
// agent doesn't exist, so unsubscribe
ss.removeAgent(ss.agents[agentId]);
}
}
}
}
};
It's still a bit of spaghetti code since optimally the SubscriptionSet should be flushed in __onDisconnect. One issue is that the Agent doesn't contain a list of channels they are subscribed too, which means that when calling onDisconnect it seems like one would have to iterate through all channels to check/delete the agent.
(sorry to open this ticket, but I'm not sure if this is a problem on my setup or with push-it...)
Node throws an invalid_state_err when trying to send a message after refreshing the browser window. I think something isn't properly clearing the list of connected agents (i.e. trying to send to a disconnected agent), but I'm not entirely sure.
This is nodejs's console.log:
Thanks for the help and please let me know if I can better further describe the issue or help replicate it.