session connect null exception

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

Moderator: uasdknet

Post Reply
marklendering
Full Member
Full Member
Posts: 6
Joined: 03 Nov 2015, 13:43

session connect null exception

Post by marklendering »

After disconnecting from the opcua server/session i sometimes get a null exception when i want to reconnect.
The session.Connect function generates this exception.

Code: Select all

EndpointDescription session_description = new EndpointDescription() { EndpointUrl = l_url, SecurityMode = MessageSecurityMode.None, TransportProfileUri = "http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary" };
                        RequestSettings settings = new RequestSettings() { OperationTimeout = 10000 };
                        equipmentTypeObject.m_session.AutomaticReconnect = true;
                        equipmentTypeObject.m_session.Connect(session_description, RetryInitialConnect.Yes, settings);
exception handling:

Code: Select all

catch (Exception ex)
            {
                if (ex == null)
                {
                    equipmentTypeObject.m_session.Disconnect();
                    equipmentTypeObject.m_session.Cache.Clear();
                    equipmentTypeObject.m_session = new Session();
                    return error.SESSION_BROKEN;
                }
                return error.SERVER_CONNECTION_FAILED;
            }
Under normal circumstances the session is always re-used. Only in case I receive the Null Exception will i create a new Session. However, this does not seem to work, as the connection just keeps failing.




Neither my own log(because the exception is null) nor the UA logs in the appdata provide any feedback.
this is the logging from the UA logs. The disconnect/connection failure started @11:12:16:

Code: Select all

11:15.50|0016|01|4|TCP CHANNEL 50266: Attempting Renew Token Now: TokenId=4
11:15.57|0054|01|4|TCP CHANNEL 143919: Attempting Renew Token Now: TokenId=4
11:16.06|0016|01|4|TCP CHANNEL 104778: Attempting Renew Token Now: TokenId=4
11:16.15|0016|01|4|TCP CHANNEL 95352: Attempting Renew Token Now: TokenId=4
11:16.23|0030|01|4|TCP CHANNEL 102581: Attempting Renew Token Now: TokenId=4
11:22.00|0030|01|4|TCP CHANNEL 2: Attempting Renew Token Now: TokenId=4




Any ideas what might be the issue here?
I guess there is a bug in the library somewhere as there is a missing exception object!
the version im currently using: 2.4.0 (BINARY Edition)

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

Re: session connect null exception

Post by Support Team »

Hello,

We do not throw null exceptions in code. This is even not allowed by C# standard.

Do you have a second catch block for the exception. There might be issues when having more than one catch block with the same variable name for the exception. Please see stackoverlow.

If this does not solve your problem then update to the newest version of the sdk and try to reproduce the issue. If it can be reproduced, then post an example to reproduce.
Best regards
Unified Automation Support Team

Post Reply