IMD SolutionComputing LibraryShop main store

Troubleshooting

Why a Node-RED OPC UA server updates values only when a client reads

Edge computing and IIoT Published 5 min read

Short answer

The address-space variables in a node-red-contrib-opcua-server flow refresh only when something reads them, so a SCADA client that subscribes or polls sees stale data. Keep the PLC-to-set-node path unchanged and add a Node-RED flow that reads the affected server variables on a repeating timer; the SCADA display then updates at that read cadence.

On this page
  1. Separate the working parts from the broken one
  2. Why only a read refreshes the value
  3. Fix it: read the server variables from inside Node-RED
  4. Worked example: pick the refresh interval from the display requirement
  5. Verify the fix without UaExpert masking it
  6. Document the read cycle as part of the design
  7. Questions asked

If your Node-RED OPC UA server serves PLC values that only refresh when UaExpert reads them, the server flow is missing its own refresh cycle. In the reported setup, values land in the address-space variables through set nodes, a read from UaExpert returns fresh data, but the SCADA client sees stale values and a subscription produces nothing. The package does not push new values into the address space on a timer; a read is what causes the stored value to refresh. Leave the PLC-to-set-node path untouched and add a second flow in the same Node-RED instance that reads the affected variables on a repeating inject. The SCADA visualization then updates as fast as that added flow reads, and that cadence is what you engineer and verify.

Separate the working parts from the broken one #

Run these checks before changing anything, because each one narrows the fault:

  • PLC values arrive and are stored in the set-node variables: the upstream path works.
  • UaExpert reads and shows changing values: the address space is served correctly and a read returns current data.
  • The SCADA display updates only after UaExpert reads the same tags: the refresh is tied to a read, not to time.
  • Changing the client's acquisition cycle changes nothing: a faster scan reads the same stale value more often.
  • A subscription reports no updates: OPC UA subscriptions report data changes, and the server never generates one here.

Every check points at one narrow fault: the server-side variable refresh. Not connectivity, not the protocol, not the client. Naming it that precisely matters, because it stops you from spending an afternoon on WinCC acquisition settings that cannot fix a value that is stale before the client ever asks for it.

Why only a read refreshes the value #

An OPC UA client gets data two ways: a read, where the server returns the current attribute values on request, and a subscription, where the server pushes a notification when a value changes. Both paths read the same address space; neither creates new values in it.

With node-red-contrib-opcua-server, the address space is populated from your flow. The observed behavior is that a read causes the stored value to refresh, and nothing in the default example flow schedules that refresh on its own. That is why UaExpert looks healthy while the SCADA client starves: UaExpert supplies the read your flow never schedules.

If you can first confirm that your flow really does write into the address space continuously and the value still goes stale, look at the community-maintained server variant node-red-contrib-opcua-server-refresh, which exists to add periodic refresh to the server. For most builds built on the standard example flow, though, the internal read below is the direct fix.

Fix it: read the server variables from inside Node-RED #

  1. Keep the existing PLC-to-set-node flow exactly as it is. It is not the fault.
  2. Add an OPC UA client read aimed at the server itself: an OPC UA client node from the same palette, with its endpoint set to the server's own endpoint address, the loopback address and port your server node publishes, for example an endpoint on 127.0.0.1.
  3. Point the read at the variables your SCADA screen uses, with the same NodeIDs the address space defines.
  4. Trigger the read with an Inject node on a repeating interval; one second is a workable start for visualization data.
  5. Deploy, then watch the SCADA display follow the inject cadence.

Keep this gateway on the visualization and logging side only: an OPC UA value refreshed on a software timer must never carry a safety function.

Worked example: pick the refresh interval from the display requirement #

Suppose the SCADA screen must show a changed PLC value within 2 s, and the client's acquisition cycle is 1 s. The display's worst-case staleness is the refresh interval plus the acquisition cycle. With the inject at 1 s, the worst case is 1 s + 1 s = 2 s, which meets the requirement exactly.

If the requirement tightened to 1 s, that inject would no longer be enough, because 1 s + 1 s = 2 s still exceeds it. You would shorten the inject to 0.5 s (0.5 s + 1 s = 1.5 s) or shorten the client cycle. Load scales the same way: one read each second against one variable is 3,600 reads per hour; against 20 variables it is 72,000 reads per hour. A modest gateway handles that, but do not multiply it past the tags the screen actually needs.

Verify the fix without UaExpert masking it #

Close UaExpert before testing, because its reads refresh the values and will hide the fault. Change a PLC value, confirm it reaches the set-node variable, and time the SCADA display against the inject interval. If the display changes at the read cadence, the fix is active. If it stays stale, check three things: the added read targets the same NodeIDs the display uses, the inject interval is actually running after deploy, and the OPC UA client node connects to the server endpoint at all. For that last check, Troubleshoot Node-RED OPC UA when UaExpert connects walks the client-side cases where one client works and another does not.

Document the read cycle as part of the design #

Record the inject interval with the gateway design, next to the PLC path and the SCADA acquisition settings. Increasing only the client's acquisition rate is not a fix here; the server value is what is stale. And if the server is reachable beyond the plant network, apply the steps in Harden a Node-RED OPC UA server exposing PLC tags before it carries production data.

Questions asked

Why does the SCADA subscription show no updates while UaExpert sees fresh data?

A subscription reports data changes, and the server never generates one because nothing refreshes the address-space value on a timer. UaExpert sees fresh data because it performs a read, and with node-red-contrib-opcua-server that read is what causes the stored value to refresh. Add the internal read flow and the subscription path starts reporting changes as the refresh writes them.

Will a faster SCADA acquisition cycle clear stale server values?

No. The SCADA client reads whatever the server stores; if the stored value is stale, a faster cycle returns the same stale value more often. The refresh has to happen in the server flow, which is why changing the acquisition interval showed no effect in the reported case.

What inject interval should the refresh flow use?

Set it from the display requirement, not from the package: worst-case staleness at the screen equals the inject interval plus the client acquisition cycle. For a screen that must show a change within 2 seconds with a 1-second acquisition cycle, a 1-second inject meets it exactly. Load grows with variable count, so refresh only the tags the visualization actually uses.

Keep reading

  • Selection guide

    Node-RED OPC UA server node selection for edge gateways

    Install node-red-contrib-opcua as the pilot OPC UA server package on the first edge gateway, through the Node-RED editor's Manage palette, and keep node-red-contrib-opcua-server as the evaluated fallback. A fleet rollout past a thousand gateways is justified only when the pilot passes the qualification table: server function, real-client interoperability, NodeId stability across restarts, quality behavior, security policy and install reproducibility, all on a recorded software stack.

    Edge computing and IIoT

  • How-to

    Save Node-RED OPC UA values to MySQL through a template insert

    Wire the OPC UA client, a Template node and the MySQL node in series. The Template node builds INSERT INTO test.prosys_table (Counter, Time) VALUES from the measured value plus Now(), and places the finished statement on msg.topic, because the MySQL node reads its query from msg.topic and returns results in msg.payload. Then prove the row with a SELECT.

    Edge computing and IIoT

  • Troubleshooting

    Why Node-RED crashes on deploy for a missing OPC UA certificate

    The crash is a local file lookup, not a network or server fault: deploying starts the OPC UA connector, the connector builds an OPC UA client, and that client throws cannot locate certificate file for its self-signed certificate before touching the network. Recover the editor in safe mode, give the Node-RED service account a writable certificate directory, redeploy, and only replace the package or move to a container if provisioning stays unmaintainable.

    Edge computing and IIoT