Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException from UaChannelBase.CreateUaBinaryChannel #2770

Open
1 of 5 tasks
Stoffelche opened this issue Sep 23, 2024 · 0 comments
Open
1 of 5 tasks

NullReferenceException from UaChannelBase.CreateUaBinaryChannel #2770

Stoffelche opened this issue Sep 23, 2024 · 0 comments
Assignees
Labels
bug A bug was identified and should be fixed. needs investigation

Comments

@Stoffelche
Copy link
Contributor

Stoffelche commented Sep 23, 2024

Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

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.

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

  1. Establish a connection as client from a debug session.
  2. Pause the debug session for a while
  3. Resume execution

Environment

- OS:
- Environment:
- Runtime:
- Nuget Version:
- Component:
- Server:
- Client:

Anything else?

No response

@mregen mregen added bug A bug was identified and should be fixed. needs investigation labels Sep 24, 2024
@mregen mregen self-assigned this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug was identified and should be fixed. needs investigation
Projects
None yet
Development

No branches or pull requests

2 participants