Close sessions for lost WebSockets to prevent zombie SyncPlay groups (#17079)

Close sessions for lost WebSockets to prevent zombie SyncPlay groups
This commit is contained in:
Enea D'Angiò
2026-07-02 19:36:48 +02:00
committed by GitHub
parent 379c58a48d
commit 8f3eb3205d
3 changed files with 159 additions and 2 deletions
@@ -246,8 +246,21 @@ namespace Emby.Server.Implementations.Session
_logger.LogInformation("Lost {0} WebSockets.", lost.Count);
foreach (var webSocket in lost)
{
// TODO: handle session relative to the lost webSocket
RemoveWebSocket(webSocket);
// The connection stopped answering keep-alives, so a close frame will
// never arrive and the pending receive loop would hang forever, keeping
// the session (and e.g. its SyncPlay group membership) alive. Disposing
// the connection aborts the receive loop, which raises Closed and lets
// the session end normally.
try
{
webSocket.Dispose();
}
catch (Exception exception)
{
_logger.LogWarning(exception, "Error disposing lost WebSocket from {RemoteEndPoint}.", webSocket.RemoteEndPoint);
}
}
}
}