fix(lmxproxy): clean up stale session subscriptions on scavenge and add stream timeout

Grpc.Core doesn't reliably fire CancellationToken on client disconnect,
so Subscribe RPCs can hang forever and leak session subscriptions. Bridge
SessionManager scavenging to SubscriptionManager cleanup, and add a
30-second periodic session validity check in the Subscribe loop so stale
streams exit within 30s of session scavenge rather than hanging until
process restart.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-03-24 15:21:06 -04:00
parent b74e139a85
commit eecd82b787
3 changed files with 58 additions and 4 deletions

View File

@@ -112,6 +112,11 @@ namespace ZB.MOM.WW.LmxProxy.Host
// 8. Create SessionManager
_sessionManager = new SessionManager(inactivityTimeoutMinutes: 5);
_sessionManager.OnSessionScavenged(sessionId =>
{
Log.Information("Cleaning up subscriptions for scavenged session {SessionId}", sessionId);
_subscriptionManager.UnsubscribeClient(sessionId);
});
// 9. Create performance metrics
_performanceMetrics = new PerformanceMetrics();