Would it be possible to periodically call something like this (every 5 minutes, for example) to find out whether SFTP sessions are getting stuck at the server?
foreach (var session in fileServer.Sessions)
{
fileServer.LogWriter.Write(LogLevel.Info, GetType90, 0, "Server", $"Session {session.Id}: IP: {session.ClientAddress} ID: {session.Context} Duration: {(int)session.Duration.TotalMinutes} min LastActivity: {session.LastActivity.ToLocalTime():yyyy-MM-dd HH:mm:ss}");
}
Additionally, there is a setting that limits the maximum idle time for SFTP sessions. Setting it to a non-zero value ensures that idle sessions are not getting stuck:
fileServer.Settings.MaxIdleDuration = 30 * 60; // 30 minutes
This is actually quite important - we have observed SFTP sessions at our test.rebex.net
server that got established successfully, but then stopped transmitting any packets (not even FIN or RST, so they were still considered active by the server and caused memory consumption to gradually grow).