Republish
If a client fails to receive a message NotificationMessage due to network packet loss, republish have the server resend it from the cache:
pub fn Subscription::republish(&self, retransmit_sequence_number: u32) -> StatusCode;
Generally, there is no need to call this.
Under normal circumstances, it is AutoPublish handled internally SDK SequenceNumber Ack, and the client is not affected. This is used only API in special scenarios (active packet recovery / debugging).
When to Use
- The client detected SequenceNumber a gap and actively filled it.
- After a temporary network outage, I want to retrieve the data from that period.
- Debugging Phase / Testing SDK Republish Behavior
Usage
let st = sub.republish(12345);
if st.is_good() {
println!("Server confirmed retransmit, data will arrive in next Publish");
} else {
eprintln!("Republish failed: {} (0x{:08X})",
darra_opcua::status_name(st), st.raw());
}
Note
- The server caches only the most recent N records ( NotificationMessage typically N = 10); any records beyond that cannot be retrieved.
republishThis is a request to the server to "resend on the next publish," not to retrieve the data directly.- The resend data is received via the normal DataChange callback; the client does not need to take any special action.
- On failure the returned StatusCode means that the message's SequenceNumber has gone past the server's retransmission queue cache (the BadMessageNotAvailable semantics in the protocol). This name is not in the constant set; use
st.raw()to get the raw code anddarra_opcua::status_name(st)to get the readable name — do not copyStatusCode::Xverbatim - The current implementation does not parse the returned content NotificationMessage; the data will be received during the next normal publish.
Difference from transfer_subscriptions
| API | Meaning |
|---|---|
| republish | The server remembers the subscription; it's just that one message was missed. |
| transfer_subscriptions | Taking Over the Subscriptions of the Old Session After a Session Reconnection |
For more information, see Session Overview.