Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Support for TransferSubscriptions
February 29, 2024
17:40, EET
Avatar
broessl
Member
Members
Forum Posts: 3
Member Since:
February 13, 2024
sp_UserOfflineSmall Offline

Hi All,

I am working to implement this feature on client-side: https://reference.opcfoundation.org/Core/Part4/v104/docs/5.13.7
I want to transfer a Subscription from Client A to Client B. An important constraint is, that Client A is running on a different process/JVM/environment than Client B.
com.prosysopc.ua.client.Subscription.transferTo(UaClient) is not an option, because the Subscription object from A is not accessible for B.
I tried the low-level approach to build and send com.prosysopc.ua.stack.core.TransferSubscriptionsRequest.TransferSubscriptionsRequest(RequestHeader, UnsignedInteger[], Boolean). I can see in server logs, that the subscription is successfully transferred. But this does not help since I don’t get a Subscription object where i can register listeners for all MonitoredItems.
I tried a workaround, where i created com.prosysopc.ua.client.Subscription with the SubscriptionID to request and then call com.prosysopc.ua.client.Subscription.transferTo(UaClient) for Client B. This does also work (on server side, StatusCodes are all good) but for each data update I get this:
com.prosysopc.ua.StatusException: Bad_MonitoredItemIdInvalid (0x80420000) “The monitoring item id does not refer to a valid monitored item.”

I guess the internal state of the Subscription object is not prepared to handle MonitoredItems which are not created using the API?
Is there any other way to implement this feature with these constraints?

March 1, 2024
9:38, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Does it have to be via TransferSubscriptions? In most cases for redundancy the secondary client could make it’s own subs+items (maybe kept in Sampling or Disabled MonitoringMode until failover and then be turned to Reporting if you need data from the failover period).

As you have noted there are some internal (OPC UA) ids. Basically the idea is that the SDK would manage things for you and there wouldn’t be a need to do raw complicated requests. Thus the SDK is also sort of unaware of any requests you make outside of it’s APIs (or even with com.prosysopc.ua.client.UaClient.serviceRequest(ServiceRequest)).

Technically the Bad_MonitoredItemIdInvalid might be workarounded by using com.prosysopc.ua.client.MonitoredItem.setClientHandle(int) (or the ‘UnsignedInteger clientHandle’ field), both are protected, thus you would need to subtype the MonitoredDataItem to access them.

Then the item could maybe be added via com.prosysopc.ua.SubscriptionBase.addItem(MonitoredItemBase, UnsignedInteger), as it seems this one doesn’t try to create the item to the server (use the ClientHandle as the second parameter).

But you might run into some other problem after that. Also, unless the original client crashed or is manually disconnected, it might eventually try to re-create the transferred Subscription, as it doesn’t expect the Subscription to be transferred to anything but future itself after a reconnect after a connection break (in the worst case it TransferSubscriptions it back to itself).

So, I think it would be probably better to contact sales@prosysopc.com and link this chain, as I think some improvements to the SDK would be needed to support this more properly.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
22 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 726

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_gallery

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1