Problems subscribing to multiple topics in rapid succession
I have an app where some web pages need to subscribe to up to 5 separate topics using long polling. Calling grails.Events.on() 5 times in a row triggers a series of 5 connections from the browser to the server. 4 of these are shut down before they have completed a subscription, due to the on() method calling unsubscribe(). The 5th connection correctly subscribes to all 5 topics.
In our case, the series of disconnects confuses network machines with connection pooling, resulting in data being sent down the wrong connection, potentially to a different user. Even without this issue, it's a bit inefficient to repeatedly connect each time we subscribe. I'm curious if anyone else has seen this behavior.
To fix this, I wrote a version of grails.Events that allows us to register topic handlers without connecting. Once all topics are registered, I call a connect() method.
Another potential fix would be to have a method that allows multiple handlers to be registered at once.