Skip to content

Added reverse connect implementation#1947

Open
Haeavar wants to merge 3 commits intoFreeOpcUa:masterfrom
Haeavar:reverse-connect
Open

Added reverse connect implementation#1947
Haeavar wants to merge 3 commits intoFreeOpcUa:masterfrom
Haeavar:reverse-connect

Conversation

@Haeavar
Copy link

@Haeavar Haeavar commented Mar 9, 2026

OPC UA Reverse Connect implementation (Part 6 §7.1.3 / Part 2 §6.14) inverts who dials the TCP socket: the server dials out to pre-configured client URIs, immediately sends a ReverseHello message, and the client then drives the rest of the OPC UA session exactly as in a normal connection (OpenSecureChannel → CreateSession → ActivateSession …).

Usage:

from asyncua import Server, ReverseConnectConfig, ReverseConnectClientEntry

server = Server()
await server.init()
server.reverse_connect = ReverseConnectConfig(
    clients=[
        ReverseConnectClientEntry(endpoint_url="opc.tcp://client-host:4840"),
    ],
    connect_interval=15_000,   # retry every 15 s
    connect_timeout=30_000,
    reject_timeout=60_000,
)
async with server:
    await asyncio.sleep(3600)

"""Maximum simultaneous sessions over this reverse connection (0 = unlimited)."""

enabled: bool = True
"""Set to ``False`` to disable this entry without removing it from the config."""
Copy link
Member

Choose a reason for hiding this comment

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

docstring after the variable. Is that normal?


# ---------------------------------------------------------------------------
# Manager
# ---------------------------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

useless comment

self.iserver: InternalServer = iserver if iserver else InternalServer(user_manager=user_manager)
self.bserver: BinaryServer | None = None
self.socket_address: tuple[str, int] | None = None
self.reverse_connect: ReverseConnectConfig | None = None
Copy link
Member

Choose a reason for hiding this comment

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

if it is a config then call it a config...

@oroulet
Copy link
Member

oroulet commented Mar 12, 2026

Can you rebase?

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.

2 participants