triplem
(triple-m)
February 21, 2024, 4:27pm
1
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!
EvgenyK
(Evgeny Karpov)
February 22, 2024, 9:16am
2
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.
triplem
(triple-m)
February 22, 2024, 9:53am
3
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.
EvgenyK
(Evgeny Karpov)
February 22, 2024, 10:18am
4
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
bugs://D19446 was closed as fixed.
triplem
(triple-m)
February 22, 2024, 12:17pm
7
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?
EvgenyK
(Evgeny Karpov)
February 22, 2024, 1:00pm
8
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.
triplem
(triple-m)
February 26, 2024, 9:17am
9
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.
EvgenyK
(Evgeny Karpov)
February 26, 2024, 9:57am
10
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);
}
triplem
(triple-m)
February 26, 2024, 10:04am
11
Makes perfectly sense now, thanks.
1 Like