Skip to main content

Republish

If a client fails to receive a message NotificationMessage due to network packet loss, Republish have the server resend it from the cache:

public StatusCode Republish(uint retransmitSequenceNumber);
Generally, there is no need to call this method.

Regular sending and receiving are handled by the SDK background Publish method (DarraOpcUa.AutoPublish which can be enabled or disabled), and the client is not affected. This method is used only API in special scenarios (such as active packet recovery or debugging).

It's hard to actually put

SDK it to use right now. Did not reveal anything SequenceNumber — DataChangeEventArgs MonitoredItemHandle / NodeId / ValueString / DataTypeName / Status / SourceTimestamp / ServerTimestamp If you don't get a notification number, thenNo gaps were detected; I don't know which one to fill..Republish(seqNo) Currently, the input parameters can only be obtained by the business side from other sources (server logs, packet captures, or agreed-upon sequence numbers).

When to Use​

  • The business side is aware that a certain item is SequenceNumber missing (for example, the server logs provide a sequence number), so they proactively fill in the gap.
  • Debugging Phase / Testing the Server Republish Behavior

Usage​

var st = sub.Republish(retransmitSequenceNumber: 12345);   // The parameter name is retransmitSequenceNumber
if (st == StatusCode.Good)
Console.WriteLine("Server confirmed retransmit, data will arrive in next Publish");
else
Console.WriteLine($"Republish failed: {st}");

Note​

  • Returns Good Indicates that the server has accepted the resubmission request, which does not mean the data will definitely be returned
  • The resubmitted data is received during the next normal publish, triggering the callback DataChanged; the client does not need to take any special action.
  • The length of the server-side retry queue is determined by its implementation (the specification does not specify a fixed number), and once a message ID has been removed from the queue, it cannot be retrieved.
  • StatusCode In the enumerationNone BadMessageNotAvailable; The "not indexed" code returned by the server will appear as a numeric value in the return value; when checking for it, simply compare the values directly or use a StatusCode.Bad catch-all clause.

Difference from TransferSubscriptions​

APIMeaning
RepublishThe server remembers the subscription; it's just that one message was missed.
TransferSubscriptionsTaking Over the Subscriptions of the Old Session After a Session Reconnection

For more information, see Session Overview.

Next Step​