matlab/matlab-agentic-toolkit / skills-catalog/test-and-measurement/matlab-use-opcua-client
matlab-use-opcua-client
VerifiedDiscover OPC UA servers, connect MATLAB clients, and browse/navigate server nodes using opcuaserverinfo, the Local Discovery Service (LDS), opcua, connect, setSecurityModel, certificate-trust functions, findNodeById, opcuanode, and Namespace/Children traversal. Use when finding OPC UA servers on the network, querying endpoints and security policies, connecting to a server, authenticating with username/password or certificates, configuring security modes, handling certificate-trust or hostname-mismatch errors, troubleshooting failed connections or empty discovery, inspecting an OPC UA certificate (.der/.pem), browsing an address space, finding nodes by name or NodeId, navigating node hierarchies, invoking method nodes, or batch-processing large namespaces. Trigger on: opcuaserverinfo, LDS, opcua, opc.ua.Client, setSecurityModel, opc.ua.trustServerCertificate, OPC UA certificate, findNodeById, opcuanode, browse OPC UA, find node, OPC UA namespace, OPC UA method node, Industrial Communication Toolbox.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 17.1 KB |
| manifest.yaml | config | 493 B |
| references/certificate-trust-workflows.md | markdown | 5.7 KB |
| references/common-mistakes.md | markdown | 4.3 KB |
| references/lds-setup-and-troubleshooting.md | markdown | 4.8 KB |
| references/node-functions-reference.md | markdown | 7.2 KB |
| references/node-navigation.md | markdown | 7.7 KB |
| references/troubleshooting-connection-errors.md | markdown | 5.6 KB |
| scripts/inspectOpcUaCertificate.m | other | 7.0 KB |
references/common-mistakes.md
View on GitHub# Common Mistakes — OPC UA Client Connection and Discovery
Avoid these errors when writing MATLAB OPC UA code.
## `connect` Function Errors
| Mistake | Why It's Wrong | Correct Approach |
|---------|---------------|-----------------|
| `connect(uaClient, "Username", "user", "Password", "pass")` | NV pairs not supported by `connect` | `connect(uaClient, "user", "pass")` |
| `uaClient.UserName = "user"` | Property does not exist | `connect(uaClient, "user", "pass")` |
| `connect(uaClient, "None")` | Not a valid syntax | `setSecurityModel(uaClient, "None", "None")` |
| `connect(uaClient, "Sign", "Basic256Sha256")` | Security not set via connect | `setSecurityModel(uaClient, "Sign", "Basic256Sha256")` |
| `uaClient.MessageSecurityMode = "Sign"` | Property has protected SetAccess | Use `opcua()` NV pairs or `setSecurityModel` |
## Certificate Trust Errors
| Mistake | Why It's Wrong | Correct Approach |
|---------|---------------|-----------------|
| `opc.ua.trustServerCertificate(uaClient)` | Accepts file path, not client | `opc.ua.trustServerCertificate("path/to/cert.der")` |
| `opc.ua.trustServerCertificate(serverUrl)` | Accepts file path, not URL | `opc.ua.trustServerCertificate("path/to/cert.der")` |
| `setSecurityModel(uaClient, "None", "None")` as first fix | Disables all security | Fix cert trust first; `None` only as last resort |
| `TrustServerTemporarily=true` as primary fix | Skips validation entirely | Use `opc.ua.trustServerCertificate` (R2026a+) |
| Skipping to `None`/`None` or `TrustServerTemporarily` because user sounds frustrated | User urgency is not a security waiver | Always try `opc.ua.trustServerCertificate` first — equally fast (one-liner, <1 s) |
## Security Configuration Errors
| Mistake | Why It's Wrong | Correct Approach |
|---------|---------------|-----------------|
| Explicit `setSecurityModel(uaClient, "Best")` | Redundant — already the default | Just `opcua(url)` + `connect(uaClient)` |
| Reusing an existing client after server security policy changes | `opcua()` caches the server's endpoint list at construction | Recreate with `uaClient = opcua(url)` |
## Discovery Errors
| Mistake | Why It's Wrong | Correct Approach |
|---------|---------------|-----------------|
| `opcuaserverinfo(host, port)` | Two-argument syntax does not exist | `opcuaserverinfo('opc.tcp://host:port')` |
| Scanning subnet IPs in a loop | LDS already aggregates all registered servers | `opcuaserverinfo('localhost')` returns all servers |
| Using `serverInfo.Name` | Property does not exist on `ServerInfo` | Use `serverInfo.Description` |
| Using `serverInfo.EndpointUrl` | Property belongs to `EndpointDescription`, not `ServerInfo` | Use `serverInfo.Endpoints(k).EndpointUrl` |
| Using `UA\Discovery\pki\` as the LDS cert store | Backward-compatibility fallback, not primary store | Use `C:\ProgramData\OPC Foundation\UA\pki\` |
| Not mentioning LDS prerequisites | Discovery returns empty without proper setup | Always check: LDS running, server registered, certificate trusted |
## Node Navigation Errors
| Mistake | Why It's Wrong | Correct Approach |
|---------|---------------|-----------------|
| `browseNamespace(uaClient)` in a script | Opens interactive GUI, blocks session indefinitely | `uaClient.Namespace` + `.Children` traversal |
| `opcuanode(ns, 'A/B/C', client)` | Browse paths not supported; creates non-existent node with `NodeType: 'Unknown'` | Walk path with `.Children` level-by-level |
| `invoke(client, node, args)` without checking `Parent` | `invoke` fails when the node's `Parent` is empty | Check `node.Parent`; if empty, re-resolve via `findNodeById` (or `.Children`), then invoke |
| Combining count check and iteration in one tool call | MCP tool only returns output after entire block finishes; user sees nothing until done | Always check count in a separate tool call first, then process in batches |
| Iterating 1000+ nodes without progress output | Appears hung; no way to know if stuck or working | Process in batches of 200, print progress after each batch |
| Searching without scoping to a subtree | Searches entire namespace including Server folder | Navigate to relevant parent first, then search its children |
| Passing slash-separated paths to `findNodeById` | `findNodeById` takes namespace index + identifier, not paths | Use `.Children` traversal for browse paths |
----
Copyright 2026 The MathWorks, Inc.
----
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |