Problem Details: OPC UA Client Fails to Connect to SINUMERIK 840D
Engineers integrating OPC UA clients with a Siemens SINUMERIK 840D sl / SINUMERIK ONE controller frequently encounter a connection rejection from the controller's embedded OPC UA server. The client application — whether it is a TIA Portal HMI, a SCADA node such as Ignition, an in-house SDK, or a generic client such as UaExpert — reports one of the following symptoms at runtime:
-
BadConnectionClosedorBadServerHaltedafter the TCP three-way handshake completes. -
BadIdentityTokenRejectedwhen the client opens a session with Anonymous identity. -
BadUserAccessDeniedon the firstServiceRequestfollowingCreateSession. - The client never even reaches
CreateSession; discovery (FindServers/GetEndpoints) returns no endpoints or returns only endpoints that the client considers insecure.
The pattern is consistent across SINUMERIK 840D sl firmware versions ≥ 4.95, SINUMERIK ONE (≥ 6.13), and SINUMERIK 828D (≥ 4.95) when the runtime configuration shipped by Siemens is not modified by the user. This article documents the four classes of root cause, the diagnostic procedure to isolate each one, and the verified remediation steps that do not require opening a Siemens support ticket.
Architecture: OPC UA Server inside SINUMERIK
The SINUMERIK OPC UA server runs as a Linux service on the NCU (Numerical Control Unit) or PCU/IPC for SINUMERIK ONE. It exposes the controller's NCK, PLC, and drive variables as a typed address space that conforms to the OPC UA Companion Specification for CNC. The server is bound to TCP port 4840 by default and listens on all configured Ethernet interfaces of the X120/X130/X127 ports on the NCU.
| Parameter | Default | Where to change |
|---|---|---|
| Listen port | 4840 (TCP) | Display Manager → netnc->opcua via sc command line, or via SINUMERIK Operate commissioning |
| Server URL | opc.tcp://<NCU-IP>:4840 |
DHCP / static IP of X120 |
| Endpoint security policies | None, Basic128Rsa15, Basic256Sha256 | Display Manager → OPC UA → Security |
| User identity tokens accepted | Anonymous (default OFF on ≥ 4.95), Username/Password, Certificate | Display Manager → OPC UA → User Management |
| Server certificate | Self-signed, generated on first start | /var/siemens/opcua/pki/own/ |
| Trusted client store | Empty until first client connects | /var/siemens/opcua/pki/trusted/ |
The configuration is read on NCU power-up; changes to port, security policy, or user accounts require a NCU reboot. Note that SINUMERIK Operate exposes only a subset of the OPC UA server's settings — for full control, edit /user/sinumerik/opcua/opal_config.xml on the CF card and reboot the NCU.
Root Cause #1: Anonymous Authentication Disabled by Default
Beginning with SINUMERIK 840D sl V4.95 SP3 (released for HF7 and later) and all V6.x firmware, Siemens ships the OPC UA server with Anonymous identity token disabled. A client that opens an endpoint and presents only an Anonymous token receives BadIdentityTokenRejected (status code 0x80210000) immediately after ActivateSession.
This is the most common cause of the failure observed in the field, especially when porting applications from earlier SINUMERIK firmware or from generic S7-1500 OPC UA samples that did not require credentials.
Diagnostic steps
- Confirm the SINUMERIK firmware version from the HMI: Commissioning → NC → NCK version. Record the full string, e.g.
04.95.07.00. - Open a Wireshark capture on the client machine and apply the filter
opcua. - Trigger a connect from the client and locate the
ActivateSessionRequestframe. - Expand OPC UA Security Header → User Identity Token → Policy Id. If it reads
anonymousthe client is the source of the problem. - Compare with a known-good client (e.g. UaExpert); the Policy Id there will read
usernameorcertificate.
Remediation
Either re-enable Anonymous on the SINUMERIK side (not recommended for production) or — preferably — configure the client to use Username/Password. On TIA Portal as an OPC UA client (TIA V17 and later):
- Project tree → Devices & networks → OPC UA communication.
- Select the configured OPC UA connection → Properties → Connection → Security → User identity.
- Set Token type to
User nameand enter the credentials of an OPC UA user defined on the NCU. - Compile and download the PLC project.
For an SDK-based client the equivalent call is documented in the OPC UA specification part 4: UaClient.setUserIdentity(userName, password) must be invoked before activateSession(). The credential must match an account defined in Display Manager → OPC UA → User Management, not an HMI or PLC password.
Root Cause #2: Endpoint Discovery Returns Wrong URLs
Clients that use FindServers followed by GetEndpoints rely on the URLs that the server publishes. On a SINUMERIK NCU those URLs are constructed from the hostname at server start. If the NCU's hostname resolves to a virtual interface, an APIPA address, or an internal IPv6 link-local address, the client receives endpoints it cannot route to.
| Symptom in Wireshark | Likely cause |
|---|---|
GetEndpointsResponse lists opc.tcp://NCU.local:4840 that does not resolve from the client subnet |
mDNS / zeroconf leakage |
Endpoint URLs contain fe80:: link-local addresses |
IPv6 default route missing |
| Endpoint URLs point to the X127 commissioning interface (192.168.214.x) but the client is on X120 | NCU reporting the wrong interface |
Remediation
- On the NCU, log in via Display Manager and execute
sc→netcfg→show. Confirm thatX120has the expected IPv4 address. - Edit
/user/sinumerik/opcua/opal_config.xmland set the<Hostname>element to the FQDN that the client network resolves correctly. - Restart the OPC UA service:
sc→opcua restart. A full NCU reboot is required for the change to persist across power cycles. - As a workaround in the client, hard-code the endpoint URL using the actual X120 IPv4 address and skip discovery. This is acceptable for point-to-point cell integrations but should be replaced by DNS-based discovery on larger plants.
Root Cause #3: Security Policy Mismatch
The SINUMERIK OPC UA server negotiates one of three security policies: None, Basic128Rsa15, or Basic256Sha256. Basic128Rsa15 is deprecated per OPC UA Specification Part 7 and is disabled by default on firmware ≥ 6.13. A client that insists on Basic128Rsa15 (for example, an older UaExpert profile) will fail to OpenSecureChannel with status BadSecurityChecksFailed (0x80120000).
Modern TIA Portal versions (V17, V18, V19) acting as OPC UA clients default to None for plain LAN segments and to Basic256Sha256 with the TIA Portal's own certificate when the user selects "Secure". If the client cannot present a certificate that the NCU's trusted-client list recognizes, the server responds with BadCertificateUntrusted (0x801A0000) during OpenSecureChannel.
Remediation — step-by-step certificate trust
- Export the client's OPC UA application certificate (DER,
.der) from the client configuration. In TIA Portal this is Options → Security settings → Certificates. - Transfer the file to a USB stick and insert it into the NCU's front USB port.
- In SINUMERIK Operate: Commissioning → Network → OPC UA → Certificates → Import client certificate.
- Reboot the NCU. The certificate is moved into
/var/siemens/opcua/pki/trusted/on power-up. - From the client side, accept the NCU's server certificate. The NCU's self-signed certificate is found at Commissioning → Diagnostics → OPC UA → Server certificate; export and import into the client trust list.
Root Cause #4: Service-Level Access Rights
This is the failure mode described in the original symptom — the client authenticates successfully with Username/Password, ActivateSession returns OK, and yet the very first read or browse returns BadUserAccessDenied (0x801F0000) or BadNotReadable (0x80140000).
On the SINUMERIK OPC UA server, user accounts are mapped to roles. Each role grants read/write access to a subset of the address space:
| Role | Granted nodes | Typical use |
|---|---|---|
Operator |
Read-only on /State, /Program, /Channel | HMI dashboards |
Maintenance |
Read/write on /Channel/MachineAxis, /Spindle | Commissioning tooling |
Integrator |
Read/write on /PLC/Memory, /NCK/Set | OEM cell software |
Admin |
Full address space | Restricted; audit-logged |
If the client uses a Username/Password pair that authenticates against an Operator account, any read on a writeable tag (or a write on a read-only tag) returns BadUserAccessDenied. This is by design and is independent of the OPC UA stack itself.
Diagnostic
- Capture a session in Wireshark and identify the first
ReadRequestafterActivateSessionResponse. - Note the NodeId in the request, for example
ns=3;s=Channel/MachineAxis/ActPos. - On the NCU, run
sc→opcua→acl who→ user name. The output lists the roles assigned to that user. - Compare with the role table above. If the role does not include the requested path, the rejection is expected.
Remediation
- Open Display Manager → OPC UA → User Management.
- Edit the user account and assign the appropriate role. For OEM integrations, prefer a dedicated
Integratoraccount over reusing an existingOperatoraccount. - Optionally restrict the role's address-space scope to a specific sub-tree using the Access control list editor. This is the recommended approach for multi-cell plants where different OEMs must see only their machine axis data.
BadIdentityTokenRejected, not BadUserAccessDenied. The latter code always means authentication succeeded but the role lacks permission for the specific NodeId.Diagnostic Procedure: Wireshark Capture and Decode
Wireshark (≥ 3.6, which added OPC UA Binary protocol dissection) is the single most useful tool for isolating any of the four root causes above. The full procedure:
- Install Wireshark ≥ 3.6 on the client machine. Confirm the opcua dissector is present: Help → About → Plugins.
- Start a capture on the interface facing the NCU. Use a capture filter
host <NCU-IP> and port 4840to reduce noise. - Trigger the connect from the client.
- Stop the capture after the first failure appears in the client log.
- Apply display filter
opcuaand inspect the conversation:
| Frame | Look for | Indicates |
|---|---|---|
Hello |
ProtocolVersion, ReceiveBufferSize | Initial handshake |
Acknowledge |
Server-side limits, server certificate URI | Server reachable |
OpenSecureChannelRequest |
SecurityPolicyUri, ClientNonce | Security policy mismatch #3 |
CreateSessionRequest |
EndpointUrl, ApplicationUri | Endpoint discovery #2 |
ActivateSessionRequest |
UserIdentityToken → PolicyId | Anonymous vs Username #1 |
First ReadRequest / BrowseRequest
|
NodeId, AttributeId | Access rights #4 |
| Corresponding Response | ServiceResult code | Maps to the four root causes above |
Wireshark's Decode As feature lets you force dissection if the port is non-standard: Decode As → OPC UA Binary on TCP port 4840.
Common OPC UA Status Codes Mapped to SINUMERIK
The status codes returned by the SINUMERIK OPC UA server follow the OPC UA Part 4 standard. The codes most frequently seen during connection setup are:
| Hex | Symbolic name | Meaning on SINUMERIK | Root cause class |
|---|---|---|---|
| 0x80000000 | BadUnexpectedError | Internal server fault, check NCU log /var/log/messages
|
— |
| 0x80140000 | BadNotReadable | Attribute not readable for this role | Role/access (#4) |
| 0x801A0000 | BadCertificateUntrusted | Client certificate not in NCU trusted list | Certificate (#3) |
| 0x801F0000 | BadUserAccessDenied | Role lacks permission for NodeId | Role/access (#4) |
| 0x80200000 | BadIdentityTokenRejected | Anonymous used but disabled, or wrong password | Authentication (#1) |
| 0x80210000 | BadIdentityTokenInvalid | Token type not offered by server | Authentication (#1) |
| 0x80220000 | BadUserSignatureInvalid | User certificate signature mismatch | Certificate (#3) |
| 0x80340000 | BadServerHalted | Server shutting down / NCU rebooting | Infrastructure |
| 0x80350000 | BadServerBusy | Subscription queue full, throttle client | Performance |
Procedure: Configuring the TIA Portal OPC UA Client to a SINUMERIK Server
For engineers using TIA Portal V17, V18, or V19 as the OPC UA client (a common configuration when a S7-1500 or S7-1500H PLC must consume CNC data from a SINUMERIK controller), the following sequence reliably establishes a session.
Prerequisites
- TIA Portal V17 Update 9 or later (V19 Update 1+ recommended for stable SINUMERIK ONE connectivity).
- SINUMERIK 840D sl ≥ 4.95 SP3 or SINUMERIK ONE ≥ 6.13.
- NCU user account of role
Integratoror higher created in Display Manager. - Ethernet connectivity on X120; NCU reachable at
ping <NCU-IP>from the engineering station.
Step-by-step
- Open the TIA Portal project that owns the S7 PLC.
- Project tree → Devices & networks → Network view → Connections.
- From the catalog, drag OPC UA → OPC UA client into the connection table.
- Right-click the connection → Properties → General. Set Server endpoint URL to
opc.tcp://<NCU-IP>:4840. -
Properties → Security:
-
Security policy:
Basic256Sha256(orNoneonly on air-gapped commissioning networks). -
Authentication mode:
User name. - Enter the Username/Password created in Display Manager.
-
Security policy:
- Compile the project. TIA Portal will warn if the certificate of the SINUMERIK server is not trusted; click Trust server certificate.
- Download to the S7 PLC.
- On the NCU side, accept the S7 PLC's client certificate (Display Manager → OPC UA → Trusted clients).
- Reboot the NCU once; subsequent connections do not require a reboot.
Verification
- In the S7 PLC's online diagnostics, open OPC UA client → Diagnostics → Connection status. The state should read
Connected. - Open a watch table referencing the imported OPC UA tags. Values should update at the configured sampling interval (default 250 ms).
- On the NCU, run
sc→opcua→sessions. The output must list the S7 PLC's ApplicationUri with roleIntegrator.
Procedure: Connecting Ignition or Third-Party SCADA
SCADA platforms such as Ignition by Inductive Automation use the same OPC UA stack but expose the client configuration through a different UI. The mapping from a SINUMERIK server is:
- In the Ignition gateway, Config → OPC UA → Servers → Create new OPC UA server connection.
-
Endpoint URL:
opc.tcp://<NCU-IP>:4840. -
Security policy:
Basic256Sha256→ Sign and Encrypt. -
Authentication:
Username & Password. - Click Discover. The Ignition client requests
GetEndpointsand populates the list. - Enable Accept server certificate on first connection.
- Browse from Config → OPC UA → Servers → Tag browser. The CNC address space appears as a tree under
/.
BadConnectionClosed against SINUMERIK ONE V6.13 because of a SessionTimeout unit mismatch (seconds vs milliseconds). Upgrade Ignition to 8.1.18+ or set the client SessionTimeout to 120000 ms.Procedure: Programmatic SDK Client (Java / .NET / C)
For an in-house SDK-based client, the canonical connect sequence must follow OPC UA Part 4 §5.6. The minimum code path that survives all four root causes is:
-
DiscoveryClient.getEndpoints(endpointUrl)— confirm the server is reachable and collect the list of supported policies. - Select the policy the client supports. If multiple are returned, prefer
Basic256Sha256. - Load or generate the client application certificate. For an SDK client, this is done with the SDK's
CertificateUtilsclass. - Call
UaClient.setApplicationUri(...),UaClient.setApplicationName(...), andUaClient.setCertificate(...). - Call
UaClient.setSecurityPolicy(policy)matching the chosen endpoint. - Call
UaClient.setUserIdentity(userName, password). Do not call the overload that sets Anonymous unless the server explicitly accepts it. -
UaClient.connect()— this internally issuesOpenSecureChannel,CreateSession, andActivateSession. - On success,
UaClient.getSession().getSessionId()returns a validNodeId. On failure, the SDK throwsUaServiceResultExceptioncarrying one of the status codes listed above.
Failure on step 7 with BadUserAccessDenied on the very next Read call confirms root cause #4. The remediation is to either change the role assignment on the NCU side or to drop the read scope to the path the role allows.
Procedure: Verifying the Fix
After applying any of the remediations above, validate with the following checklist:
| Check | Command / UI path | Expected result |
|---|---|---|
| TCP reachability |
Test-NetConnection <NCU-IP> -Port 4840 (PowerShell) or nc -vz <NCU-IP> 4840
|
TcpTestSucceeded : True |
| Endpoint discovery | UaExpert → Add server → Custom discovery | Endpoint listed with selected policy |
| Session creation | UaExpert → Connect with Username/Password | Connected; no BadIdentityTokenRejected
|
| Browse root | UaExpert → Server → Browse root | Address-space tree visible |
| Read sample tag | Drag ns=3;s=Channel/State/ChannelState into DataView |
Value updates without error |
| NCU audit |
sc → opcua → sessions
|
One active session, role matches |
| TIA Portal side | Online → Diagnostics → OPC UA | Status Connected, last error None
|
Troubleshooting Matrix
Map the failure mode to the root cause and the fix in one table:
| Symptom | Status code | Root cause | Fix |
|---|---|---|---|
| Connection refused at TCP level | — | Wrong port, firewall, NCU OPC UA service stopped | Check nc -vz; restart with sc opcua start
|
| Discovery returns empty | — | DNS / hostname #2 | Fix Hostname in opal_config.xml
|
Discovery returns only None policy |
— | Server has no cert installed | Generate server certificate via Display Manager |
ActivateSession rejected |
0x80200000 |
Anonymous #1 | Use Username/Password |
OpenSecureChannel rejected |
0x80120000 |
Security policy #3 | Match Basic256Sha256
|
OpenSecureChannel rejected |
0x801A0000 |
Certificate trust #3 | Import client cert into NCU trusted list |
First Read rejected |
0x801F0000 |
Role scope #4 | Adjust role or change NodeId |
| Periodic disconnect every 60 s | 0x80340000 |
NCU rebooting, SessionTimeout too short | Raise SessionTimeout to 120 s |
Safety and Operational Notes
/NCK/Set/... paths are subject to the same access-key protections as the HMI. Treat any OPC UA write as equivalent to an OEM-level write for change-management purposes.Reference: Official Siemens Documentation
Authoritative material on the OPC UA server embedded in SINUMERIK controllers is published in the following manuals, all available on the Siemens Industry Online Support portal:
- SINUMERIK 840D sl / SINUMERIK ONE OPC UA Server Programming Manual — describes the address space, role model, and the configuration file
opal_config.xml. - SINUMERIK Operate Commissioning Manual — section on OPC UA user management in Display Manager.
- TIA Portal Help → Configuring OPC UA — client configuration in V17, V18, V19.
- OPC UA Specification Parts 4 and 7 published by the OPC Foundation — normative status codes and security policies referenced throughout this article.
Why does my OPC UA client receive BadIdentityTokenRejected against a SINUMERIK 840D even though the same credentials work in UaExpert?
SINUMERIK firmware ≥ 4.95 SP3 disables Anonymous identity by default. If your client uses an Anonymous token while UaExpert uses Username/Password, the server rejects the client with status code 0x80200000. Configure the client to call setUserIdentity(userName, password) before activating the session, and create a matching OPC UA user account in Display Manager → OPC UA → User Management.
TIA Portal V17 cannot find the OPC UA server of our SINUMERIK — UaExpert can. What is wrong?
This is typically a hostname / endpoint URL problem. Confirm the endpoint URL is the NCU's X120 IPv4 address (for example opc.tcp://192.168.1.10:4840) and not a hostname or link-local address. In opal_config.xml, set <Hostname> to the FQDN that TIA Portal can resolve, or hard-code the endpoint URL in TIA Portal's connection properties.
OpenSecureChannel fails with BadCertificateUntrusted — where do I put the TIA Portal client certificate?
Export the TIA Portal OPC UA client certificate (DER, .der) and import it via Display Manager → OPC UA → Certificates → Import client certificate, then reboot the NCU. The certificate is moved into /var/siemens/opcua/pki/trusted/ on power-up. On the client side, also trust the NCU's self-signed server certificate.
My client authenticates successfully but the first Read returns BadUserAccessDenied. Why?
Authentication succeeds, but the user's role (Operator, Maintenance, Integrator, Admin) does not grant access to the NodeId being read. Check the role with sc → opcua → acl who on the NCU and either assign a higher role to the user or restrict the read to a NodeId within the user's role scope.
What is the default port, and can I move the OPC UA server to a non-standard port?
The SINUMERIK OPC UA server listens on TCP 4840 by default. The port can be changed in Display Manager or by editing opal_config.xml, but the change only takes effect after an NCU reboot. Always update the firewall rules and the client endpoint URL together with any port change.