OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.94k stars 942 forks source link

Fix reopen secure channel without activate #2577

Closed mregen closed 4 months ago

mregen commented 6 months ago

Proposed changes

If a socket is closed, new service calls are queued and a new channel is established without reconnect / activate. Add some logic which ensures that a BeginConnect operation is only started if a valid service call is queued first. The activate is prepared by the session reconnect handler which may take some time to respond. Until then, all other service fail immediately with BadNotConnected. To detect socket failures earlier, the PublishRequest and KeepAlive send are also hooked up to the KeepAliveError to trigger a reconnect. To disable the keep alive timing calcualtion, an additional variable tracks the statuscode of the last error to set KeepAliveStopped to true.

Related Issues

Types of changes

What types of changes does your code introduce? Put an x in the boxes that apply. You can also fill these out after creating the PR.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 58.71560% with 45 lines in your changes are missing coverage. Please review.

Project coverage is 54.52%. Comparing base (52d4492) to head (e61785b). Report is 1 commits behind head on master.

Files Patch % Lines
Libraries/Opc.Ua.Client/Session.cs 71.05% 9 Missing and 2 partials :warning:
...k/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs 66.66% 8 Missing and 3 partials :warning:
Libraries/Opc.Ua.Client/SessionAsync.cs 23.07% 9 Missing and 1 partial :warning:
Libraries/Opc.Ua.Client/SessionReconnectHandler.cs 33.33% 4 Missing :warning:
Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryChannel.cs 50.00% 1 Missing and 2 partials :warning:
...pc.Ua.Core/Stack/Tcp/UaSCBinaryTransportChannel.cs 25.00% 2 Missing and 1 partial :warning:
...ack/Opc.Ua.Core/Stack/Tcp/ChannelAsyncOperation.cs 60.00% 1 Missing and 1 partial :warning:
Stack/Opc.Ua.Core/Stack/Client/ClientBase.cs 75.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2577 +/- ## ========================================== - Coverage 54.64% 54.52% -0.12% ========================================== Files 343 343 Lines 65218 65270 +52 Branches 13354 13365 +11 ========================================== - Hits 35637 35591 -46 - Misses 25702 25794 +92 - Partials 3879 3885 +6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

KircMax commented 5 months ago

Is this 'ready to be tried out'? If so can I somehow get a pre-release of a NuGet Package to do so?

romanett commented 5 months ago

Is this 'ready to be tried out'? If so can I somehow get a pre-release of a NuGet Package to do so?

preview nugets are available for every merge to master.

So for open PRs it is easiest to clone the branch and build a nuget locally (using dotnet pack).

mregen commented 5 months ago

Hi @KircMax, unfortunately this work isn't finished and I had to suspend for a bit. I let you know when it is ready for test. Thanks for your help and interest in the topic.

mregen commented 4 months ago

Is this 'ready to be tried out'? If so can I somehow get a pre-release of a NuGet Package to do so?

Hi @KircMax, I hope we have a Nuget preview out by end of the week.

KircMax commented 4 months ago

Sounds great! :)