Skip to content

Make reverse connect lifecycle fully asynchronous#4059

Open
marcschier wants to merge 5 commits into
masterfrom
marcschier/async-reverse-connect-lifecycle
Open

Make reverse connect lifecycle fully asynchronous#4059
marcschier wants to merge 5 commits into
masterfrom
marcschier/async-reverse-connect-lifecycle

Conversation

@marcschier

@marcschier marcschier commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add cancellation-aware asynchronous start, lazy initialization, stop, reload, and disposal for ReverseConnectManager
  • make listener replacement transactional with explicit ownership, rollback/restoration, stale watcher protection, and deterministic concurrent start/stop/dispose behavior
  • add injectable async configuration providers, remove the former protected configuration hooks, and retain obsolete synchronous lifecycle compatibility wrappers
  • integrate eager Generic Host startup plus non-host lazy startup, including custom application-configuration providers
  • serialize ReverseConnectHost lifecycle and extend raw TCP, Kestrel TCP, WSS, hosting, concurrency, rollback, and NativeAOT coverage
  • document the async lifecycle, hosting behavior, cancellation guarantees, provider model, and migration path

Validation

  • Opc.Ua.Client Release build across all supported target frameworks
  • reverse-connect client and core tests on net10.0 and net48
  • raw TCP, Kestrel TCP, and WSS integration tests on net10.0; raw TCP on net48
  • NativeAOT publish and 115-test executable run

Closes #4013.

Related: #3985, #4009.

Copilot AI review requested due to automatic review settings July 19, 2026 23:07
@marcschier
marcschier marked this pull request as draft July 19, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Makes reverse-connect startup/shutdown fully async across core + DI + samples, and expands tests/docs to cover cancellation, host integration, and restart/rollback scenarios.

Changes:

  • Update test fixtures and integration tests to use DisposeAsync / async teardown patterns.
  • Add async DI lifecycle support (hosted service + async config provider model) and document migration path.
  • Extend ReverseConnectHost with serialized async open/close/dispose behavior and add extensive concurrency/teardown tests.

Reviewed changes

Copilot reviewed 22 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Opc.Ua.Sessions.Tests/WssReverseConnectIntegrationTests.cs Switches fixture teardown to async disposal.
tests/Opc.Ua.Sessions.Tests/ReverseConnectTest.cs Converts one-time teardown to async disposal.
tests/Opc.Ua.Sessions.Tests/KestrelTcpReverseConnectIntegrationTests.cs Switches fixture teardown to async disposal.
tests/Opc.Ua.Core.Tests/Stack/Client/ReverseConnectHostTests.cs Adds disposal + concurrency/serialization coverage for ReverseConnectHost.
tests/Opc.Ua.Client.Tests/ClientBuilder/ReverseConnectManagerTests.cs Disables obsolete warnings to cover sync compatibility wrappers.
tests/Opc.Ua.Client.Tests/ClientBuilder/ClientReverseConnectOptionsTests.cs Adds DI/host/lazy/eager startup + provider + restart overlay tests.
tests/Opc.Ua.Client.TestFramework/TestFixture.cs Updates teardown to DisposeAsync.
tests/Opc.Ua.Client.TestFramework/ClientTestFramework.cs Updates teardown to DisposeAsync.
tests/Opc.Ua.Client.TestFramework/ClientFixture.cs Introduces IAsyncDisposable and async teardown path for fixtures.
tests/Opc.Ua.Aot.Tests/HostingAotTests.cs Extends AOT coverage to resolve reverse-connect services.
src/Opc.Ua.Core/Stack/Client/ReverseConnectHost.cs Adds IAsyncDisposable and serializes lifecycle operations with deterministic teardown.
src/Opc.Ua.Client/Opc.Ua.Client.csproj Adds hosting abstractions reference for hosted-service integration.
src/Opc.Ua.Client/NugetREADME.md Documents async reverse-connect lifecycle + DI behavior.
src/Opc.Ua.Client/IReverseConnectConfigurationProvider.cs Adds injectable async configuration provider API + default pass-through impl.
src/Opc.Ua.Client/Fluent/ReverseConnectManagerHostedService.cs Adds hosted service to eagerly start/stop manager under Generic Host.
src/Opc.Ua.Client/Fluent/OpcUaClientOptions.cs Updates options docs to reflect eager/lazy async startup.
src/Opc.Ua.Client/Fluent/OpcUaClientBuilderExtensions.cs Registers provider + hosted service; updates manager activator for async startup model.
src/Opc.Ua.Client/Fluent/ClientReverseConnectOptions.cs Updates docs to describe hosted + lazy startup behavior.
samples/ConsoleReferenceClient/Program.cs Migrates sample to StartServiceAsync / DisposeAsync.
docs/migrate/2.0.x/transport-listener-async.md Documents new async reverse-connect lifecycle + migration steps.
docs/migrate/2.0.x/README.md Updates migration index entry to include reverse-connect changes.
docs/ReverseConnect.md Updates canonical reverse-connect docs for async + DI/provider lifecycle.

Comment thread src/Opc.Ua.Core/Stack/Client/ReverseConnectHost.cs
Comment thread tests/Opc.Ua.Core.Tests/Stack/Client/ReverseConnectHostTests.cs
Comment thread tests/Opc.Ua.Core.Tests/Stack/Client/ReverseConnectHostTests.cs Outdated
Comment thread src/Opc.Ua.Client/ReverseConnectManager.cs Outdated
Comment thread src/Opc.Ua.Client/ReverseConnectManager.cs Outdated
@marcschier
marcschier marked this pull request as ready for review July 20, 2026 05:53
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.08163% with 90 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.15%. Comparing base (12f770b) to head (39ccb59).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
...c.Ua.Client/Fluent/OpcUaClientBuilderExtensions.cs 6.45% 58 Missing ⚠️
...lient/Fluent/ReverseConnectManagerHostedService.cs 0.00% 16 Missing ⚠️
src/Opc.Ua.Core/Stack/Client/ReverseConnectHost.cs 88.69% 12 Missing and 1 partial ⚠️
....Ua.Client/IReverseConnectConfigurationProvider.cs 0.00% 3 Missing ⚠️

❌ Your patch check has failed because the patch coverage (54.08%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

❗ There is a different number of reports uploaded between BASE (12f770b) and HEAD (39ccb59). Click for more details.

HEAD has 73 uploads less than BASE
Flag BASE (12f770b) HEAD (39ccb59)
82 9
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #4059       +/-   ##
===========================================
- Coverage   73.86%   34.15%   -39.72%     
===========================================
  Files        1345      894      -451     
  Lines      180038   130233    -49805     
  Branches    31678    23757     -7921     
===========================================
- Hits       132993    44483    -88510     
- Misses      36290    79898    +43608     
+ Partials    10755     5852     -4903     
Files with missing lines Coverage Δ
src/Opc.Ua.Client/Fluent/OpcUaClientOptions.cs 87.50% <ø> (-12.50%) ⬇️
src/Opc.Ua.Client/ReverseConnectManager.cs 7.27% <ø> (-65.29%) ⬇️
....Ua.Client/IReverseConnectConfigurationProvider.cs 0.00% <0.00%> (ø)
src/Opc.Ua.Core/Stack/Client/ReverseConnectHost.cs 90.07% <88.69%> (-4.37%) ⬇️
...lient/Fluent/ReverseConnectManagerHostedService.cs 0.00% <0.00%> (ø)
...c.Ua.Client/Fluent/OpcUaClientBuilderExtensions.cs 16.29% <6.45%> (-65.35%) ⬇️

... and 1033 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

Make ReverseConnectManager startup and reload lifecycle fully asynchronous

2 participants