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

There would be crash on client when reconnect with SessionReconnectHandler.BeginReconnect if using reverse connect. #2951

Open
1 of 5 tasks
JohnJiang26821 opened this issue Jan 22, 2025 · 3 comments

Comments

@JohnJiang26821
Copy link

Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

  1. Implement reverse connect for my UA client based on the OPC UA .NET Standard Library.
  2. UA server offline.
  3. UA client uses SessionReconnectHandler and ReverseConnectManager to reconnect.
  4. Sometime there would be BadSessionIdInvalid case, that result in m_session.DetachChannel in SessionReconnectHandler::DoReconnectAsync, that clear the member "Endpoint" info of session.
  5. When re-create the session, there would be m_reverseConnectManager.WaitForConnection who will use m_session.Endpoint that was cleared by previous step, it results in crash.

Expected Behavior

No matter how, there would be no crash.

Steps To Reproduce

No response

Environment

- OS:
- Environment:
- Runtime: 
- Nuget Version: OPC UA .NET Standard Library 1.5.375-eccpreview
- Component:
- Server:
- Client:

Anything else?

No response

@JohnJiang26821
Copy link
Author

JohnJiang26821 commented Jan 23, 2025

Solution for this issue, and no problems after my test.
Is there anyone who can review the code changes?

The file needs to be revised is SessionReconnectHandler.cs within Libraries\Opc.Ua.Client\Session
At line 462, the changes as below:

var endpointDes = m_session.Endpoint;
if(endpointDes == null)
 endpointDes = transportChannel.EndpointDescription;

connection = await m_reverseConnectManager.WaitForConnection(
 new Uri(endpointDes.EndpointUrl),
 endpointDes.Server.ApplicationUri
).ConfigureAwait(false);

@romanett
Copy link
Contributor

romanett commented Feb 1, 2025

@JohnJiang26821 thanks for finding a solution please open it as a pull request then it can be reviewed

@JohnJiang26821
Copy link
Author

@romanett
Sure, done it, please help review the code changes, will appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants