Subscription Model (Subscription)
The OPC UA subscription model solves "how does a client get real-time updates when server data changes", and is far more efficient than polling Reads.
- Service Set — Subscription / List of Services MonitoredItem
- Example — Multi-Point Subscription Collection — Get the minimum subscription up and running
- Example — Large-Scale Monitoring — 1000+ MI Optimizations
Conceptual Structure
Session (1) ── owns ──▶ Subscription (N) ── contains ──▶ MonitoredItem (M)
│
└── publishes ──▶ NotificationMessage
- Subscription This is the publishing context, which determines the publishing interval (the interval between server-side pushes).
- MonitoredItem (MI) This is a single monitoring target (one NodeId+ Attribute), which determines the sampling interval.
- NotificationMessage This is a server-side push data packet containing the latest values MI for a set of items.
Publish / Republish Mechanism
OPC UA is a "client-pull" model — the client must keep sending PublishRequest, and the server answers with a PublishResponse carrying a NotificationMessage when new data is available.
Client Server
│ ──PublishRequest──────────────▶ │
│ │ (no data, hold)
│ ──PublishRequest──────────────▶ │
│ ◀──PublishResponse(NotifMsg1, seq=10)
│ ──PublishRequest+ack(seq=10)──▶ │
│ ◀──PublishResponse(NotifMsg2, seq=11)
│ ...
Darra OPC UA ClientSDK AutoPublish = true Once enabled, an internal background thread automatically manages the Publish queue, so users don't have to worry about it.
If a client fails to receive a message NotificationMessage due to a network issue, the client can send a request to Republish(seqNo) have the server resend that SequenceNumber message (the server caches the most recent N messages by default).
Key Parameters for Subscription
| Parameters | Default | Note |
|---|---|---|
| publishingIntervalMs | 500 | Minimum interval for server-side pushes (subject to change by the server) |
| lifetimeCount | 1200 | If no response is received after a certain number of publish cycles, the client PublishRequest is considered dead. |
| maxKeepAliveCount | 50 | How often should an empty KeepAlive notification be sent when there is no new data? |
| priority | 0 | Priority (When There Are Multiple Subscriptions in a Single Session) |
The server will "revise" these parameters (adjusting them to a range it can accept) and Modify return a RevisedXxx to inform the client of the actual values that take effect.
MonitoredItem Key Parameters
| Parameters | Default | Note |
|---|---|---|
| samplingIntervalMs | -1 (Subscribe) | Minimum interval for server-side sampling |
| queueSize | 1 | How many unsent data points should the server MI buffer for this? |
| discardOldest | true | When the queue is full, discard the oldest / newest item |
| monitoringMode | Reporting | Disabled (Sampling Suspended) / Sampling (Sampling Only, No Reporting) / Reporting (Sampling and Reporting) |
| filter | DataChangeFilter | Data Change Trigger Conditions (Absolute Deadband / Percentage Deadband) |
DataChangeFilter (Dead Zone)
Not every minor change needs to be pushed—configuring a dead zone can reduce noise:
| DeadbandType | Meaning |
|---|---|
| None | Any changes are pushed |
| Absolute | A push notification is sent only when the change in value exceeds the absolute value threshold. |
| Percent | Push notifications are sent only when the percentage change in the value exceeds EURange. |
TransferSubscriptions (Cross-Session Migration)
After a session disconnects and reconnects, the old subscription may still be active on the server (not yet cleaned up), and the new session can TransferSubscriptions take over these subscriptions without having to rebuild everything MI:
ua_new.TransferSubscriptions(oldSubscriptionIds, sendInitialValues: true);
Returns the status for each subscription StatusCode; "Good" indicates that the migration was successful. Immediately after the migration, the current values are pushed once (sendInitialValues=true), allowing clients to receive the new notifications right away.
One-Time vs. Long-Term Subscription
- Short-term: Create, use, and dispose; server-side cleanup
- Long-term: KeepAlive is automatically maintained until the session is disconnected
- Very Long-Term (Cross-Session): Works in conjunction with takeover after TransferSubscriptions reconnection