We are saving the handle returned by
when we subscribe to a RIC. When we are no longer interested, we call
with the saved handle.
It looks like EMA reuses handles and we are facing the following issue.
- We subscribe to let's say instrument ABCD, we get back handle for it, let's say x.
- We get a onStatusMsg callback saying stream is closed, we don't have permission or the record could not be found. We queue the instrument ABCD for unsubscribe with handle x. It looks like behind the scene EMA has already unsubcribed that handle and thinks handle x is free to reuse.
- We subscribe to instrument EFGH, we get back handle x for it.
- Our queued unsubcription for instrument ABCD calls unregister with handle x. This causes unsubscribe for instrument EFGH as EMA beleives handle x is now associated with instrument EFGH subscription.
- We beleive we are subscribed for instrument EFGH but never get a callback as EMA already unsubscribed it.
So it looks like the handle returned by registerClient becomes invalid at some point as it is no longer associated with the instrument we subscribed for. When does it happen? Is there a documentation for it? When should we not call unregister?