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
Determining if there's an active subscription
December 20, 2016
16:59, EET
Avatar
Mark Petty
Member
Members
Forum Posts: 11
Member Since:
October 26, 2016
sp_UserOfflineSmall Offline

Hi,

I’m attempting to handle some program flow issues and am looking for some pointers for where should I should be looking.

(1) if my client application crashes after creating a subscription; how would I (a) determine if that subscription(s) are still active, and (b) terminate them? I’ll have lost my Client object.

(2) As an alternate path, is there a way to determine if the server already has a session with the same credentials and then kill that session (and one assumes its subscriptions) and restart it?

-Thanks
-Mark

December 20, 2016
17:55, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello Mark,

Are you aiming to delete the previous session and the associated subscriptions? Or is your aim to move the previous subscriptions to a newly created session?

Sessions are terminated by the OPC UA server automatically if the client fails to issue a service request within the timeout period. Also, each subscription has its own lifetime to protect against data loss in the case of a session termination. In Prosys OPC UA Java SDK, the default value of session timeout is one hour and the value can be set with UaClient.setSessionTimeout method. For Subscriptions, there’s a “requestedLifetimeCount” parameter that you can supply when creating the subscription. The default value is 60 meaning that 60 times publishing interval will be waited before subscription times out (relatively low value in my mind). For both parameters, the server actually decides what value it wants to use and returns the revised value as a response.

So, if you only want to delete the previous session and subscriptions, you can just set correct timeout values and let the server delete previous session and subscriptions.

On the other hand, if you would like to move the previous subscription to a new session, you can accomplish this with the TransferSubscriptions service. But if I understood correctly, this is not what you are looking for.

December 21, 2016
21:50, EET
Avatar
Mark Petty
Member
Members
Forum Posts: 11
Member Since:
October 26, 2016
sp_UserOfflineSmall Offline

Hi, thanks for the response.

I guess my first question is if my application is being restarted, is there any way to find a previous session?

If I can’t find it am I then relying on the subscription timing out?

Are there any issues with creating a second subscription that would basically replicate the first one?

-Thanks
-Mark

December 22, 2016
16:10, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi Mark,

No, in practice you won’t be able to use the previous session. That being said, I’m not completely sure if connecting to the previous session could be achieved in some ‘non-standard’ way by persisting the session data. Anyway, creating a new session is really what you should do in this situation.

You can rely on the fact that the server will remove the previous session once it timeouts.

As for the question “Are there any issues with creating a second subscription that would basically replicate the first one?”:
The short answer is that no, there’s no issues and you should do this. I would actually recommend that you just create new subscriptions if you have no special reason to do otherwise.

The longer answer is that the advantage of transferring subscriptions instead of creating new subscriptions is that notifications that the server sampled while client was unavailable are not lost. If the previous subscriptions are transferred to the new session and queues in the server were long enough, then the client can potentially be restarted without lost notification data.

However, if your application doesn’t need the notifications that were generated during the client restart, then you can just create new subscriptions. I guess this might use a little bit more resources in the server application as the server samples data for the old and new subscription simultaneously. This is however negligible and you can also influence this by setting a short timeout for subscriptions. The benefit in creating new subscriptions is that the client application will be simpler as you don’t have to persist the subscription id values that would be needed in the TransferSubscriptions service call.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
19 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: 730

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin

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

Administrators: admin: 1