opc-ua-client icon indicating copy to clipboard operation
opc-ua-client copied to clipboard

Notifications via IObservable lost.

Open PhilJollans opened this issue 9 months ago • 0 comments

We are doing some stress testing, by generating a lot of rapid updates from an Opc-UA server.

We have subsciribed to notifications on a ClientSessionChannel using something like:

_channelSession.Subscribe(OnPublish, OnPublishError) ;

To provoke an error, we have added a delay to the OnPublish method using Task.delay(50).wait() which blocks the thread.
In this scenario, we lose notifications.

50ms is a long delay, and not at all realistic, but I wanted to find out what was happening. :smile:

Internally, responses are posted to a BroadcastBlock<T> object. So far as I can tell, BroadcastBlock<T> does not manage an internal queue. If the multiple targets which are linked to BroadcastBlock<T> do not process the object quickly enough. it may be overwritten.

Instead of using .Subscribe(), I have coded something like

var block_buffer = new BufferBlock<PublishResponse>();
_channelSession.LinkTo(block_buffer);
block_buffer.AsObservable().Subscribe(OnPublish, OnPublishError);

So far, this is working well for me.
Of course, with a 50ms delay, the BufferBlock<T> will eventually overflow, but that is not a realistic scenario.

I am not an expert on the TPL Dataflow classes, but I don't think the implementation IObservable based on the BroadcastBlock<T> class is bullet proof.

PhilJollans avatar Apr 30 '24 14:04 PhilJollans