It’s unclear from documentation/ method API (& [lack of ] comments), that the heartbeat keep alive only functions as expected if notify is called (which includes code to clear stale subscriptions).
Heartbeat is a keep alive, if not received within a certain time frame e.g. every 10 seconds, subscriptions are supposed to go stale, I would have expected stale subscriptions to be removed automatically.
There is no background thread/ timer that automatically removes stale subscriptions.
IServerEvents gives no information on most recent heartbeat per subscription, because it just returns SubscriptionInfo objects, which don’t have a LastPulse property. This indicated to me that idle subscriptions should be automatically taken care of. But it’s not automatically taken care of, the only way MemoryServerEvents will remove stale/ idle subscriptions, is when
Maybe you assumed Notify will be called regularly in the use cases you envisioned, therefore you didn’t have to make MemoryServerEvents explicitly check every so often for stale connections?
Right, by design it doesn’t have a background thread to periodically clean up stale connections and relies on SSE notifications to handle clean up. I’ll look at expanding this to also perform clean ups during regular heartbeat intervals to mitigate SSE connections with low activity.
There’s now a ServerEventsFeature.HouseKeepingInterval option to throttle the min time for expired subscriptions to be removed in this commit. This is used in RemoveExpiredSubscriptions() to throttle scanning of expired subscriptions which is called on each heatbeat.