Paolo ponzano - 230 - Sep 12, 2014

Demis a question about ServiceEvents… I’ve a page in Asp.Net that subscribe for events when a user performs a particular action… the same user can perform this action again during the applicationlife (contextualizing some products) , I’ve seen that on the server that there’re 2 subscribers (I’m the only one developing it so it re-adds another subscriber on refresh)

What should I do to avoid it?  Thanks

In short this is how it works. Each time you load a page and call $().handleServerEvents() a new subscription is registered representing the active connection. If you’re authenticated then you will have multiple subscriptions sharing the same userId. One way to minimize it is to avoid reloading the page if you can, i.e. by using Ajax.

The subscriptions themselves are managed by periodic heartbeats and auto unregistering events fired when the browser navigates away from the page. Sometimes when a window is closed the autounregistering event isn’t fired, so it falls back to heartbeats to tell if the connection is alive, because there is no way on the server to tell if the browser still maintains an active connection, i.e. it still lets you write to the response without error.

paolo ponzano:

I’m taking a look at this since w3wp get stucked after some test usage on refresh/subscription actions… I don’t know if it’s a servicestack problem or of the KendoUI Autocomplete…