Page 1 of 1

USER_DISCONNECT event not always providing access to session

Posted: 16 Nov 2024, 09:45
by ciaoamigos
Hello everyone,

I'm using the following event handler:

Code: Select all

addEventHandler(SFSEventType.USER_DISCONNECT, UserDisconnectHandler.class);


I have a question regarding its behavior. Is the USER_DISCONNECT event always triggered when a user disconnects? I noticed that in some cases, I can access the user session like this:

Code: Select all

User user = (User) event.getParameter(SFSEventParam.USER);
Session session = (Session) user.getSession();

But other times, I encounter an issue where the session is null. I was wondering:

Is the event always triggered for every disconnection?
What could cause the issue when accessing the session? The session should always be available, but it seems to be null in certain cases.
Thanks for your help!

Re: USER_DISCONNECT event not always providing access to session

Posted: 18 Nov 2024, 09:11
by Lapo
Hi,
the Session object is supposed to be available 100% of the times. With null Session the User itself couldn't exist. In other words you could not login.

We would need a repro-case, i.e. all the necessary information to trigger the problem, to be able to investigate.
If you have more data let us know.

Thanks