Event stream: send an explicit "attached" acknowledgement so clients can register advises without racing the first event #227

Closed
opened 2026-11-11 13:22:41 -05:00 by dohertj2 · 1 comment
Owner

From lmxopcua#865 (2026-11-11). The gateway never replays events to a newly opened event stream. A client that subscribes (SubscribeBulk) before its stream is attached loses the initial value, which matters for slow-changing attributes such as ScanState.

OtOpcUa now opens the stream before registering and waits up to 1 s after sending the stream request. That narrows the race but can't close it, because the gateway gives no signal that the stream is attached. Please add an initial 'stream attached' message, or a per-session sequence, so clients can wait for it deterministically. Related: the #859 worker-sequence request for SubscribeBulk replies.

From lmxopcua#865 (2026-11-11). The gateway never replays events to a newly opened event stream. A client that subscribes (SubscribeBulk) before its stream is attached loses the initial value, which matters for slow-changing attributes such as `ScanState`. OtOpcUa now opens the stream before registering and waits up to 1 s after sending the stream request. That narrows the race but can't close it, because the gateway gives no signal that the stream is attached. Please add an initial 'stream attached' message, or a per-session sequence, so clients can wait for it deterministically. Related: the #859 worker-sequence request for SubscribeBulk replies.
Author
Owner

Done on main afd504d5 — opt-in attach ack. Proto (additive): StreamEventsRequest.emit_stream_attached = 3; MxEvent.stream_attached = 15 (StreamAttached{live_after_sequence}); capability string 'stream-events-attached-ack' in OpenSessionReply.capabilities. Sent as the first message only after the subscriber is registered with the session (before the ReplayGap sentinel on resume); never on a refused attach or when not requested.

Opt-in, not always-on, because ScadaBridge's RealMxGatewayClient advances its resume cursor from every event's WorkerSequence before filtering, so an unrequested worker_sequence-0 message would reset it (latent same bug with ReplayGap filed as ScadaBridge#128). .NET client: StreamEventsAsync(…, emitStreamAttached), IsStreamAttached, SupportsStreamAttachedAck, OpenEventStreamAsync(after, attachTimeout, ct). Go/Python/Rust bindings regenerated (Java not). Tests: gateway 1446/0 (race proof verified to fail when the ack precedes registration), client 158/0, Go/Python/Rust green.

Needs an mxgw Contracts/Client release before OtOpcUa can consume it — tracked as lmxopcua#877.

Done on main afd504d5 — opt-in attach ack. Proto (additive): StreamEventsRequest.emit_stream_attached = 3; MxEvent.stream_attached = 15 (StreamAttached{live_after_sequence}); capability string 'stream-events-attached-ack' in OpenSessionReply.capabilities. Sent as the first message only after the subscriber is registered with the session (before the ReplayGap sentinel on resume); never on a refused attach or when not requested. Opt-in, not always-on, because ScadaBridge's RealMxGatewayClient advances its resume cursor from every event's WorkerSequence before filtering, so an unrequested worker_sequence-0 message would reset it (latent same bug with ReplayGap filed as ScadaBridge#128). .NET client: StreamEventsAsync(…, emitStreamAttached), IsStreamAttached, SupportsStreamAttachedAck, OpenEventStreamAsync(after, attachTimeout, ct). Go/Python/Rust bindings regenerated (Java not). Tests: gateway 1446/0 (race proof verified to fail when the ack precedes registration), client 158/0, Go/Python/Rust green. Needs an mxgw Contracts/Client release before OtOpcUa can consume it — tracked as lmxopcua#877.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/mxaccessgw#227