we get a NullReferenceException in CreateUaBinaryChannel resulting from the messageContext paramter which is null.
This null comes from the ClientBase.MessageContext property, because m_channel is null.
We assume the m_channel is set to null in a first attempt to Reconnect:
DoReconnectAsync is called and handles as ServiceResultException. Here m_session.DetachChannel() ist called
Then with the next Reconect attempt it has the null m_channel resulting in the NullReferenceException
We are using the Nuget version 1.5.374.78, but I don't think anything with respect to this problem has changed.
This is our callstack (note the line numbers are completely messed up, I think because of the async calls, but anyway it is from the mention version).
After this the session is not able to reconnect anymore, running into the NullReferenceException again and again.
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Opc.Ua.Core
StackTrace:
at Opc.Ua.UaChannelBase.CreateUaBinaryChannel(ApplicationConfiguration configuration, EndpointDescription description, EndpointConfiguration endpointConfiguration, X509Certificate2 clientCertificate, X509Certificate2Collection clientCertificateChain, IServiceMessageContext messageContext) in Opc.Ua\UaChannelBase.cs:line 393
Opc.Ua.Core.dll!Opc.Ua.UaChannelBase.CreateUaBinaryChannel(Opc.Ua.ApplicationConfiguration configuration, Opc.Ua.EndpointDescription description, Opc.Ua.EndpointConfiguration endpointConfiguration, System.Security.Cryptography.X509Certificates.X509Certificate2 clientCertificate, System.Security.Cryptography.X509Certificates.X509Certificate2Collection clientCertificateChain, Opc.Ua.IServiceMessageContext messageContext) Line 393
at Opc.Ua\UaChannelBase.cs(393)
Opc.Ua.Client.dll!Opc.Ua.Client.Session.PrepareReconnectBeginActivate(Opc.Ua.ITransportWaitingConnection connection, Opc.Ua.ITransportChannel transportChannel) Line 3667
at Opc.Ua.Client\Session.cs(3667)
Opc.Ua.Client.dll!Opc.Ua.Client.Session.ReconnectAsync(Opc.Ua.ITransportWaitingConnection connection, Opc.Ua.ITransportChannel transportChannel, System.Threading.CancellationToken ct) Line 4957
at Opc.Ua.Client\Session.cs(4957)
Opc.Ua.Client.dll!Opc.Ua.Client.Session.ReconnectAsync(System.Threading.CancellationToken ct) Line 4928
at Opc.Ua.Client\Session.cs(4928)
Opc.Ua.Client.dll!Opc.Ua.Client.SessionReconnectHandler.DoReconnectAsync() Line 265
at Opc.Ua.Client\SessionReconnectHandler.cs(265)
Opc.Ua.Client.dll!Opc.Ua.Client.SessionReconnectHandler.OnReconnectAsync(object state) Line 217
at Opc.Ua.Client\SessionReconnectHandler.cs(217)
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 515
at System.Threading\ExecutionContext.cs(515)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 486
at System.Threading\ExecutionContext.cs(486)
mscorlib.dll!System.Threading.TimerQueueTimer.CallCallback() Line 200
at System.Threading\TimerQueueTimer.cs(200)
mscorlib.dll!System.Threading.TimerQueueTimer.Fire() Line 158
at System.Threading\TimerQueueTimer.cs(158)
mscorlib.dll!System.Threading.TimerQueue.FireNextTimers() Line 252
at System.Threading\TimerQueue.cs(252)
Expected Behavior
Session recovery should work
Steps To Reproduce
Establish a connection as client from a debug session.
Type of issue
Current Behavior
we get a NullReferenceException in CreateUaBinaryChannel resulting from the messageContext paramter which is null. This null comes from the ClientBase.MessageContext property, because m_channel is null. We assume the m_channel is set to null in a first attempt to Reconnect: DoReconnectAsync is called and handles as ServiceResultException. Here m_session.DetachChannel() ist called
Then with the next Reconect attempt it has the null m_channel resulting in the NullReferenceException We are using the Nuget version 1.5.374.78, but I don't think anything with respect to this problem has changed.
This is our callstack (note the line numbers are completely messed up, I think because of the async calls, but anyway it is from the mention version). After this the session is not able to reconnect anymore, running into the NullReferenceException again and again.
Expected Behavior
Session recovery should work
Steps To Reproduce
Environment
Anything else?
No response