Add client-side failover to CLI tool for redundancy testing
All commands gain --failover-urls (-F) to specify alternate endpoints. Short-lived commands try each URL in order on initial connect. The subscribe command monitors KeepAlive and automatically reconnects to the next available server, re-creating the subscription on failover. Verified with live service start/stop: primary down triggers failover to secondary, primary restart allows failback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -162,6 +162,21 @@ Application URI: urn:localhost:LmxOpcUa:instance1
|
||||
|
||||
The command also supports `--username`/`--password` and `--security` options for authenticated or encrypted connections.
|
||||
|
||||
### Client Failover with `-F`
|
||||
|
||||
All CLI commands support the `-F` / `--failover-urls` flag for automatic client-side failover. When provided, the CLI tries the primary endpoint first and falls back to the listed URLs if the primary is unreachable.
|
||||
|
||||
```bash
|
||||
# Connect with failover — uses secondary if primary is down
|
||||
dotnet run -- connect -u opc.tcp://localhost:4840/LmxOpcUa -F opc.tcp://localhost:4841/LmxOpcUa
|
||||
|
||||
# Subscribe with live failover — reconnects to secondary if primary drops mid-stream
|
||||
dotnet run -- subscribe -u opc.tcp://localhost:4840/LmxOpcUa -F opc.tcp://localhost:4841/LmxOpcUa \
|
||||
-n "ns=1;s=TestMachine_001.MachineID"
|
||||
```
|
||||
|
||||
For long-running commands (`subscribe`), the CLI monitors the session KeepAlive and automatically reconnects to the next available server when the current session drops. The subscription is re-created on the new server.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Mismatched ServerUris between instances** -- Both instances must list the exact same set of ApplicationUri values in `Redundancy.ServerUris`. If they differ, clients may not discover the full redundant set. Check the startup log for the `Redundancy.ServerUris` line on each instance.
|
||||
|
||||
Reference in New Issue
Block a user