Page 1 of 1

Detecting web api log off and ServiceStack session end

PostPosted: Sat Mar 03, 2018 1:35 pm
by SBarnes
Hi Mike

Further to the post below, would there be now or in fixing DEV-6510 a way to setup hooking into the logging off of the web api and/or the ServiceStack session end so that other functionality could fire at the same time?

What I am asking about if the Jiwa database was being used possibly with extra tables to hold some sort of session state information how could you delete it when the session ends or the user logs off?

https://forums.jiwa.com.au/viewtopic.php?f=32&t=912

Re: Detecting web api log off and ServiceStack session end

PostPosted: Sat Mar 03, 2018 5:17 pm
by Mike.Sheen
Hi Stuart,

I've looked into the session timeout and rediscovered why we never implemented it - it's not possible to detect a session timeout!

This response from the ServiceStack maintainer states:
There is no event you can catch and no callback is possible for Session Timeouts which happens when the Caching provider transparently expires the cache entries.


I'll explore as part of DEV-6510 how we can deal with this - at the very least when a user authenticates, we can insert into a table some information including session id and expiration date, and every request which extends the session we can update that expiration date - so we should be able to work out from that when a session has expired. I'd rather not have a polling routing in the api to look for expired sessions and try to log them off - but that's a fallback position if all else fails - I'll try to work something out.

Mike

Re: Detecting web api log off and ServiceStack session end

PostPosted: Sun Mar 04, 2018 6:21 am
by SBarnes
Hi Mike,

Thanks for the update, I suppose if you go with the table solution one option would then be to have a scheduled plugin as part of the API to do the clean up by scanning the session table and at least setting the user to logged off and do the clean up.

One thing that would however be useful would be an event to allow some sort of functionality when the API is logged onto and logged off from, whilst I know there is the loggedon and loggedoff events on the manager, I don't believe however you can tell if its from the API at the moment.

Thanks.

Re: Detecting web api log off and ServiceStack session end

PostPosted: Sat May 19, 2018 10:50 am
by SBarnes
For anyone who needs a work around to this topic issue https://forums.jiwa.com.au/viewtopic.php?f=32&t=912

The following scheduled in a batch file under windows should do the job, it must run with Admin privileges to work though.

Code: Select all
sc stop JiwaAPISelfHostedService.exe

ping -n 16 127.0.0.1 > NUL

sc start JiwaAPISelfHostedService.exe

Re: Detecting web api log off and ServiceStack session end  Topic is solved

PostPosted: Tue May 22, 2018 1:53 pm
by Mike.Sheen
Thanks for that, Stuart.

FYI I've implemented a solution in DEV-6510 - I can't provide a complete plugin implementing this because our current 07.01.01 REST API plugin has dependencies on unreleased code - but I did update the DEV issue with the code snippets to implement this - and these will work with the existing 07.01.00 REST API Plugin.

So, for the adventurous, copying and pasting the snippets from DEV-6510 into the 07.01.00 plugin will see this addressed.

Re: Detecting web api log off and ServiceStack session end

PostPosted: Wed May 23, 2018 8:32 am
by SBarnes
Thanks Mike

any update on a release date for 07.01.01?

Re: Detecting web api log off and ServiceStack session end

PostPosted: Fri May 25, 2018 9:41 pm
by Mike.Sheen
SBarnes wrote:Thanks Mike

any update on a release date for 07.01.01?


I'm gunning for a DEV build towards the end of next week - it'll be at least few weeks after that before a public release is ready.