IMDHMIControls LibraryShop main store

Troubleshooting

Why the OPC UA secure channel times out on an S7-1200

SCADA and data logging Published 8 min read

Short answer

BadTimeout on OpenSecureChannel means the client gave up mid-handshake, not that the certificates were rejected. Trust the current certificates on both ends, prove the secure endpoint with a second client, and if the timeout persists with the CPU in RUN, establish the session with the CPU in STOP for about one minute, return it to RUN, and repeat the sequence after every client reboot.

On this page
  1. What BadTimeout followed by OpenSecureChannel means
  2. Trust the current certificates on both ends
  3. Prove the endpoint with a second client
  4. Example: what a rise of 2 counts every 40 seconds tells you
  5. Establish the session with the CPU in STOP
  6. Watch the existing S7 connections while the client retries
  7. The decision for each case
  8. Questions asked

When a secure OPC UA client logs BadTimeout followed by OpenSecureChannel against an S7-1200, the client abandoned the secure-channel handshake before the CPU finished it — a timing failure, not a certificate rejection. The fix runs in three steps: trust the certificates actually presented on both ends, prove the secure endpoint with a second client, and if the handshake still expires while the CPU is in RUN, open the session with the CPU in STOP for about one minute and then return it to RUN — the session stays up. The numbers below come from a reported case, an S7-1211 on firmware 4.5 with TIA Portal V17 and a client whose handshake timeout could not be configured, and each step is written so you can run it on your own CPU.

What BadTimeout followed by OpenSecureChannel means #

IEC 62541, the OPC UA specification, orders every protected session the same way: client and server open a secure channel first — security policy negotiated, certificates exchanged and validated, session keys derived — and only then move tag data. The sequence is fixed by the standard; how long a client waits before abandoning it is that client's own timeout, not a value the CPU publishes. BadTimeout followed by OpenSecureChannel in the log therefore says the handshake began and the client's waiting time ran out — the security policy itself can be perfectly valid.

Sort the log against these signatures before changing any setting:

  • CertificateValidation at connect: one side rejected the other's certificate. This is a trust fault; fix it in the certificate stores, not in timing.
  • BadCertificateChainIncomplete: the presented certificate could not be validated — re-export the certificate the device holds now, not an older copy saved on your engineering station.
  • BadTimeout then OpenSecureChannel: the handshake started and expired mid-flight. Clear trust first anyway, then move to the second-client test.
  • Tags flagged faulty and browsing reporting the OPC UA server not ready: consequences of the closed channel, and they clear once it opens.

In the reported case the entries appeared in that order, which is what made the certificate trail look convincing while the real constraint stayed hidden until a second client connected.

Trust the current certificates on both ends #

On the CPU side in TIA Portal: export the client's own certificate, import it into the project's certificate manager, assign it to the CPU's list of trusted client certificates, and download the project. On the client side: open the certificate the S7-1200 presents at connection time and trust that one. Both ends then need the same selection, Basic256Sha256 with Sign and Encrypt — a mismatch between the ends fails the handshake outright, and the matching end-to-end certificate exchange is exactly what a UaExpert client connected to a PLCnext OPC UA server with Basic256Sha256 sets up step by step.

Expect one trap: a self-signed server certificate can be regenerated, so a refresh of the client's server page can offer a brand-new certificate right after you trusted the previous one. Inspect and accept the certificate offered at the moment of connection, every time, and treat a suddenly untrusted certificate as a new certificate rather than a broken trust store. Sign and Encrypt signs and encrypts what follows the handshake; whether OpenSecureChannel always encrypts messages works through that boundary in detail.

In the reported case, complete mutual trust — the client certificate imported and assigned in TIA Portal, the current CPU certificate accepted on the client — was necessary but not sufficient: the timeout pair kept coming. Trust repairs CertificateValidation and BadCertificateChainIncomplete; it does not buy the handshake more time. If the server is a B&R PLC instead of an S7-1200, the equivalent client-certificate trust has its own documented procedure — trusting the OPC UA client certificate on a B&R PLC walks through it.

Prove the endpoint with a second client #

Put a desktop OPC UA test client — UaExpert is the usual choice — on a laptop attached to the same network, point it at the same CPU, select Basic256Sha256 with Sign and Encrypt, accept the server certificate it presents, then browse and read. If the second client connects encrypted and exchanges values, the CPU's secure endpoint, its certificate and the policy selection are all proven good, and the fault lives inside the failing client. Run this test before changing anything else; one move splits the problem in half. In the reported case the laptop client browsed nodes and read and wrote values with encryption active while the failing client kept logging its timeout pair. The same UaExpert timeout signature appears against other controllers when a handshake runs long — the UaExpert BadTimeout case on an ET 200SP open controller documents the pattern and its fix.

Example: what a rise of 2 counts every 40 seconds tells you #

Inputs, each from the reported case's client diagnostics: the S7-protocol read-error counter IsoTcpCReadErr; a rise of 2 counts recorded for each failed OPC UA connection attempt; a steady cadence of one attempt every 40 s while the failing secure client sat enabled; and a 1 h planning window for how much disturbance an endlessly retrying client adds.

Rule in words: because each failed attempt adds its counts to the counter, the interval between counter steps is the client's retry period, so attempts per hour = (60 s ÷ interval) × 60 min, and the counter's hourly rise = attempts per hour × counts per attempt.

Arithmetic: attempts per minute = 60 ÷ 40 = 1.5; attempts per hour = 1.5 × 60 = 90; counter rise per hour = 90 × 2 = 180 counts.

Result: the failing client re-opened the secure channel about every 40 s — roughly 90 failed handshakes and 180 counter counts an hour, indefinitely, until the client was stopped or the channel opened.

Decision: a counter climbing at about 2 counts per 40 s, only while the secure client is enabled, is the timeout-retry loop — apply the STOP sequence below and expect the climb to stop once the channel opens. If the counter moves only when a second client connects, the attempts are colliding with the CPU's other communication; schedule the attempt inside a STOP window instead of letting the client retry all day.

Establish the session with the CPU in STOP #

With trust verified and the endpoint proven, the remaining constraint is the client's fixed timeout against a CPU busy in RUN. The reported sequence:

  • Under an approved shutdown, switch the CPU from RUN to STOP and hold it there for about one minute.
  • Let the client attempt its connection while the CPU is in STOP; in the reported case the secure channel opened with encryption active during this window.
  • Return the CPU to RUN and confirm the session: browsing succeeds, the tag fault marks clear, and read and write pass.
  • Repeat the whole sequence after every client reboot — the established session survived the return to RUN in the reported case, but a fresh handshake while in RUN timed out again.

Switch to STOP only under an approved machine shutdown procedure; STOP puts the CPU into its configured stop response, so the machine must be safe to hold there. Read the outcome plainly: this is an observed workaround on the tested CPU and client firmware, not a documented firmware correction. The decision it hands you is still firm — the policy works, the endpoint works, connection establishment is what fails — so keep the session up and re-run the sequence only when the client reboots, rather than dismantling certificates again.

Watch the existing S7 connections while the client retries #

The failing attempts did not stay inside the OPC UA conversation. In the reported case, during connection attempts the client's separate S7-protocol tag connection flipped from status 1 to status 2 and back, a second OPC UA client logged ConnectionWarningWatchdogTimeout, and the read-error counter climbed steadily whenever the failing client sat enabled. The working explanation is that each attempt consumes communication resources on the CPU and starves its S7-protocol answers — the symptoms match, but that is case evidence, not a published resource rule for this CPU. Sharing one port among several conversations is its own sizing question; whether one S7 CPU port can carry Modbus TCP and S7 connections together covers it. Watch the other connections while you test, and once the channel is up leave it up: a connected session was quiet; only the retry loop disturbed the rest.

The decision for each case #

  • Only CertificateValidation or BadCertificateChainIncomplete in the log: repair trust on both ends with the certificates currently presented; done when encrypted browsing and read/write pass.
  • Second client connects encrypted, the failing client times out: the endpoint is sound and the client's timeout is the constraint; use the STOP-for-one-minute sequence and plan on repeating it after client reboots.
  • Channel opens in STOP and survives RUN: keep the session up, watch the counter and the other S7 connections, and re-run the sequence only on client reboot until the client offers a configurable timeout.
  • Counter climbs at the steady cadence or S7 connections flip status during attempts: treat it as contention — stop the permanent retrying, schedule attempts deliberately, and choose a client with an adjustable timeout if reboots are frequent.
  • Tempted to fall back to security None with anonymous access to make it easy: do not standardize on it; it removes every check the handshake performs and leaves the published tags open to anyone on the link.

Questions asked

Can I leave security set to None while I sort the certificates out?

Only while commissioning on an isolated bench link. Security policy None with anonymous authentication let the reported case browse, read and write PLC tags without any certificate, which means anyone who reaches that port can do the same. Use the unsecured profile to prove the data path, then move to Basic256Sha256 with Sign and Encrypt and stay there.

What has to work on the S7-1200 before certificates matter?

The OPC UA server must be enabled and its runtime license selected, a global data block must allow access from OPC UA clients, and a server interface must publish the tags you need. The reported case proved all of that with the unsecured profile first, which is what made the secure-channel diagnosis meaningful.

Does the session drop when the CPU returns to RUN?

No. In the reported sequence the secure channel was established while the CPU sat in STOP, and the session plus its tag read and write stayed intact after the return to RUN. What broke it was rebooting the client: the fresh handshake then timed out again until the STOP sequence was repeated.

Can the client's secure-channel timeout be raised?

Not in the tested client. Its firmware fixed the handshake waiting time, with no setting exposed, which is why the sequence with the CPU in STOP exists at all. Check the client vendor's release notes for a build with an adjustable timeout, or standardize on a client whose timeout you can set.

How far does this diagnosis carry across firmware versions?

The observations come from one CPU, an S7-1211 on firmware 4.5 with firmware 4.4 also tried, an engineering station on TIA Portal V17, and one client build. Handshake timing is exactly what firmware updates move, so repeat the second-client test and the STOP sequence after any update before you rely on the workaround.

Keep reading

  • Troubleshooting

    Fix Modicon M340 OPC UA UMAS protocol error by firmware

    The UMAS protocol error is a CPU firmware limit, not a client fault: the same client and project connect to M340 CPUs on firmware 2.60 and fail on 2.00 and 2.10 with DataDictionary verified. Upgrade the old CPUs to firmware 3.40 and raise the application's CPU type version in Control Expert to match.

    SCADA and data logging

  • Troubleshooting

    Why a ControlLogix OPC UA struct reads Bad_DecodingError in Ignition

    Bad_DecodingError means the read reached the controller and the structure came back, but the client had no codec to decode it: Ignition 8.1 builds structure codecs from the legacy OPC Binary DataTypeDictionary, while the Logix server describes the UDT through the OPC UA 1.04 DataTypeDefinition attribute. Confirm with one atomic member read and a UaExpert attribute check, then read members over the native Logix driver or test on Ignition 8.3.

    SCADA and data logging

  • How-to

    Connect an S7-1500 to SCADA over OPC UA from TIA Portal

    The S7-1500 has a built-in OPC UA server from firmware V2.0, deactivated by default. Enable it in the CPU device properties in TIA Portal, select the installed server license, copy the endpoint URL, and download. Paste the opc.tcp address into any OPC UA SCADA client, trust the certificates on both sides, then browse the PLC variables and map them to SCADA tags.

    SCADA and data logging