Detecting client disconnect during login

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
jonathang
Hero Member
Hero Member
Posts: 32
Joined: 02 Nov 2015, 19:07

Detecting client disconnect during login

Post by jonathang »

Dear Support Team,

I am developing an OPC UA Server using your .NET Server SDK and ran into a rare problem with not being able to detect a disconnect from an OPC UA client while the client's login credentials are being checked.

When a client connects to our server, we use the SessionManager_ImpersonateUser event to check the username and password with a remote database. Most of the time this works fine but occasionally, the client times out before we get back the database results. In those cases, the SessionManager_SessionClosing event is not invoked and the SessionManager.GetSessions() shows that the client's session is still present. It appears that this session never times out so the non-connected client is never disconnected from the server.

From testing, I noticed that the sequence of events is SessionManager_SessionCreated -> SessionManager_ImpersonateUser -> SessionManager_SessionActivated. When the situation above occurs, SessionManager_SessionActivated is never invoked.

Is there a way to detect that a client disconnected before SessionManager_SessionActivated is invoked?

Based on documentation,
If a Client disappears, the Session and all resources allocated will be freed by the SessionManager after a timeout period expires.
Is this also true if the client's session has not been activated?

http://documentation.unified-automation ... ManagerEtc

Sincerely,

Jonathan

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: Detecting client disconnect during login

Post by Support Team »

Hello,

If a session is not activated before the minimum session timeout is reached, the session will be deleted automatically. You can notice this when the SessionClosing EventHandler is called after the ImpersonateUser EventHandler (and before SessionActivated).

You should configure the MinSessionTimeout of your server application. The MinSessionTimeout shall be the maximum time that ImpersonateUser EventHandler can take.
Best regards
Unified Automation Support Team

Post Reply