Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

Proposed changes

Adds --rc / --reverseconnect command line parameter to ConsoleReferenceServer to enable reverse connection mode. The client already supported this via the same parameter, but the server could not be configured from the command line, causing "Waiting for the reverse connection timed out" exceptions when users attempted reverse connect workflows.

Changes:

  • Added --rc parameter to server that calls AddReverseConnection() post-startup
  • Added error handling for invalid URLs with UriFormatException
  • Created README.md for both server and client with usage examples
  • Resolved merge conflicts with master branch (integrated provisioning mode feature)

Usage:

# Server initiates connection to client endpoint
dotnet ConsoleReferenceServer.dll --rc=opc.tcp://localhost:65300 -a

# Client listens for reverse connection
dotnet ConsoleReferenceClient.dll --rc=opc.tcp://localhost:65300 opc.tcp://localhost:62541/Quickstarts/ReferenceServer

Related Issues

Types of changes

  • Enhancement (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

The implementation leverages ReferenceServer's existing inheritance from ReverseConnectServer. No new abstractions or server types required—just exposing existing functionality via CLI. Pattern matches the client implementation and aligns with ReverseConnectTest.cs.

Merge conflicts with master branch have been resolved—the provisioning mode feature from master is now integrated alongside the reverse connect functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>Getting 'Waiting for the reverse connection timed out' exception on trying to do OPC Reverse connect from OPC UA Client program.</issue_title>
<issue_description>1.reverse connection with opcua server
2.used the following code:

Uri endpointURI = new Uri("opc.tcp://127.0.0.1:4862/ - [None:None:Binary]");
if (endpointURI != null)
                    {
                        // start the reverse connection manager
                        m_reverseConnectManager = new ReverseConnectManager();
                        m_reverseConnectManager.AddEndpoint(endpointURI);
                      
                        m_reverseConnectManager.StartService(config);
                    }           
              
                    Console.WriteLine("2 - Discover endpoints of {0}.", server.EndPointUrl);

                    EndpointDescription selectedEndpoint;
                    if (m_reverseConnectManager == null)
                    {
                        selectedEndpoint = CoreClientUtils.SelectEndpoint(server.EndPointUrl, true, 15000);
                    }
                    else
                    {
                        Console.WriteLine("   Waiting for reverse connection."+DateTime.Today);
                        ITransportWaitingConnection connection = await m_reverseConnectManager.WaitForConnection(
                            new Uri(server.EndPointUrl), null, new CancellationTokenSource(60000).Token);
                        if (connection == null)
                        {
                            throw new ServiceResultException(Opc.Ua.StatusCodes.BadTimeout, "Waiting for a reverse connection timed out.");
                        }
                        selectedEndpoint = CoreClientUtils.SelectEndpoint(config, connection, true, 15000);
                    }
m_reverseConnectManager.WaitForConnection throws the following exception  :
Opc.Ua.ServiceResultException
  HResult=0x80131500
  Message=Waiting for the reverse connection timed out.
  Source=Opc.Ua.Client
  StackTrace:
   at Opc.Ua.Client.ReverseConnectManager.<WaitForConnection>d__19.MoveNext()
   at OPCUAConnector.Server_connection.<ConsoleSampleClient>d__2.MoveNext() in 

</issue_description>

<agent_instructions>Please add reverse connection mode to console server & client activated by command line parameter</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@mregen reverse connection sample should be added to console sample

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 3, 2025
@CLAassistant
Copy link

CLAassistant commented Dec 3, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ marcschier
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 3 commits December 3, 2025 06:06
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Co-authored-by: romanett <7413710+romanett@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix reverse connection timeout exception in OPC UA Client Add reverse connect command line support to ConsoleReferenceServer Dec 3, 2025
Copilot AI requested a review from romanett December 3, 2025 06:16
@romanett romanett marked this pull request as ready for review December 3, 2025 06:50
@marcschier
Copy link
Collaborator

@copilot please resolve the merge conflicts with master branch

Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 3, 2025

@copilot please resolve the merge conflicts with master branch

Resolved merge conflicts with master branch in commit bc975c9. The changes now include both the reverse connect functionality from this PR and the provisioning mode feature from master.

Copy link
Contributor

@romanett romanett left a comment

Choose a reason for hiding this comment

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

Tested! Reverse connection is established with the provided parameters

@marcschier marcschier merged commit 6693b12 into master Dec 4, 2025
129 of 130 checks passed
@romanett romanett deleted the copilot/fix-reverse-connection-timeout branch December 20, 2025 15:26
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.

Getting 'Waiting for the reverse connection timed out' exception on trying to do OPC Reverse connect from OPC UA Client program.

4 participants