Session Management - Session does not expire as expected

Hi,

When a (manually killed) client session (07d) is re-established within the session timeout, that session (07d) doesn’t expire after 300s as expected. Instead, that session (07d) expires later, triggered by the expiration of the re-established session (f7c) reaching the session timeout after killing manually again.

I’m using the following environment:

  • InMemorySessionManager
  • PerClientClassFactory
  • RemObjects .Net SDK v10.0.0.1581
  • SuperTcpServerChannel
  • SessionManager.Timeout = 300s

Server Log (redacted):

2024-02-21 16:07:59.359 [INF] [TID 202] Client - Login successful! (SessionCount: 1) | UserID: 5 | Hostname: Test01 | SessionID: 07dbf8a1-97b1-4685-8414-a8aba13492eb
-> Client session (07d) killed manually
-> New client session started (before session timeout)
2024-02-21 16:08:45.039 [INF] [TID 202] Client - Login successful! (SessionCount: 2) | UserID: 5 | Hostname: Test01 | SessionID: f7cddef0-e9e6-4f62-94a8-a969bb41521c
-> Client session (f7c) stays alive
2024-02-21 16:09:44.649 [DBG] [TID 202] KeepAlive (SessionCount: 2) | UserID: 5 | HostName: Test01 | SessionID: f7cddef0-e9e6-4f62-94a8-a969bb41521c
2024-02-21 16:10:44.648 [DBG] [TID 202] KeepAlive (SessionCount: 2) | UserID: 5 | HostName: Test01 | SessionID: f7cddef0-e9e6-4f62-94a8-a969bb41521c
2024-02-21 16:11:44.645 [DBG] [TID 202] KeepAlive (SessionCount: 2) | UserID: 5 | HostName: Test01 | SessionID: f7cddef0-e9e6-4f62-94a8-a969bb41521c
2024-02-21 16:12:44.640 [DBG] [TID 202] KeepAlive (SessionCount: 2) | UserID: 5 | HostName: Test01 | SessionID: f7cddef0-e9e6-4f62-94a8-a969bb41521c
2024-02-21 16:13:44.646 [DBG] [TID 202] KeepAlive (SessionCount: 2) | UserID: 5 | HostName: Test01 | SessionID: f7cddef0-e9e6-4f62-94a8-a969bb41521c
-> Expecting session (07d) to expire after 300s
2024-02-21 16:14:44.651 [DBG] [TID 202] KeepAlive (SessionCount: 2) | UserID: 5 | HostName: Test01 | SessionID: f7cddef0-e9e6-4f62-94a8-a969bb41521c
-> Client session (f7c) killed manually
2024-02-21 16:19:55.596 [DBG] [TID 213] Session expired | SessionID: f7cddef0-e9e6-4f62-94a8-a969bb41521c
2024-02-21 16:19:55.596 [DBG] [TID 213] Session expired | SessionID: 07dbf8a1-97b1-4685-8414-a8aba13492eb
-> Now both sessions (07d, f7c) have expired after 300s

Why is the first session (07d) not expiring after 300s?
Thank you for your help!

Hi,

How do you calc KeepAlive (SessionCount: 2) ?
just check Count or check Expired for each session too?

Session can be in list but it can be already Expired and just isn’t deleted from session list.

Hi Evgeny,

Thank you for your reply.
I’m doing a simple Count() on a GetAllSessions() guid list:

SessionCount = SessionManager.GetAllSessions()
	.Select(sessionGUID => SessionManager.GetSession(sessionGUID))
	.Count();

According to the docs, GetAllSessions() only returns non-expired sessions.

Hi,

actually, it just returns all sessions:

		public override IList<Guid> GetAllSessions()
		{
			this.fLock.AcquireReaderLock(MemorySessionManager.DEFAULT_LOCK_TIMEOUT);
			try
			{
				return new List<Guid>(this.fSessions.Keys);
			}
			finally
			{
				this.fLock.ReleaseReaderLock();
			}
		}

as a workaround, you can call MemorySessionManager.ExpireSessions manually

Logged as bugs://D19446.

bugs://D19446 was closed as fixed.

Under the assumption that the fix for bugs://D19446 only covers GetAllSession(), what about the problem that sessions do not seem to expire (after the timeout) under the circumstances mentioned in the initial post?

Hi,

it covers GetAllSession and Count property too. as a result, you shouldn’t see any expired sessions in MemorySessionManager anymore.


I think, I need your testcase for reviewing if this issue is still relevant.

Can you create a simple testcase that is reproduced this case, pls?

You can drop email to support@ for keeping privacy.

Hi Evgeny,

In the making of that simple test case for your further investigations, I’ve recognized that the GetSession() method in my session counter is updating the LastAccessedTime attribute of the sessions.

In this case, the KeepAlive, which is also counting the sessions, is constantly “touching” the sessions, preventing them from timing out.

I now use GetExistingSession() instead, having the possibility to prevent the method from updating the LastAccessedTime attribute.

Maybe it would be worth mentioning in the docs that GetSession() is also “touching” the session.

Thanks again for your help and support.

Hi,

In general, when you call GetSession it means that you should work with this session so LastAccessedTime attribute is updated automatically.


public interface ISessionManager
{
        Boolean IsOutOfProcess { get; }

        ISession GetSession(Guid sessionId);
        ISession GetExistingSession(Guid sessionId, Boolean updateTime);
        IList<Guid> GetAllSessions();

        void ReleaseSession(ISession session);
        void DestroySession(Guid sessionId);
}

Makes perfectly sense now, thanks.

1 Like