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
Reconnecting client to previous session/subscription after JVM restart
April 1, 2015
10:21, EEST
Avatar
BenC
Member
Members
Forum Posts: 6
Member Since:
April 1, 2015
sp_UserOfflineSmall Offline

Hi,

I recently got assigned to a project that uses the Prosys OPC UA Java SDK. We’ve got the problem that network connection stability issues can result in our client never receiving alarm events from the server. Going a step further, I’d also like to be able to make our application receive missed alarm events after a JVM restart (e.g. due to application restarts or deployments).

I spent the last 2 days reading Prosys Java SDK tutorials, JavaDocs, blog articles, and tried to get my OPC UA client to somehow get alarm events from the server that were missed. Here’s where I currently stand:

What works: my client connects to the server, creates a MonitoredEventItem with a listener, and receives notifications when I trigger alarms on the server side. I also created a MonitoredDataItem with a listener to see how that compares to the MonitoredEventItem – this also works.
What doesn’t work as I expect: when I shut down the client, trigger an alarm on the server, and restart the client, then this alarm event is not received by the client. The current MonitoredDataItem’s value is queried immediately.

Some things I tried:

– client.setAutoReconnect(true) / client.setKeepSubscriptions(true). The server keeps the sessions and subscriptions for a while after the client shuts down (JVM termination), but after connecting again, a new session/subscription is assigned and the previous ones just lie around on the server and never get used again.

– client.setSessionName(“SomeConstant”). The server still created new sessions (same name, but different ids), rather than reusing an existing session.

– client.setAutoReconnect(false) / client.reconnect(). This doesn’t work after a JVM restart; it seems this is only possible if you’ve called connect() once. But connect() creates a new session/subscription, which I don’t want.

– subscription.readAll(0d, TimestampsToReturn.Both). This only returned data items, but no missed alarm events.

Note: I’m using version 1.5.0 of the Prosys SDK. Also, I tried these tests with the non-secure security mode and an anonymous user token policy.

What else can I try? Does the OPC UA standard or Prosys Java SDK support sessions/subscriptions reconnects after JVM restarts? If not, what’s the most robust possible solution to avoid missing alarm events?

Thanks for any help,

Ben

April 1, 2015
11:01, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

You are right that this is not a trivial case, although OPC UA supports this kind of feature. However, the SDK does not really support it at the moment, not even in 2.1.0.

This would require that the client application could persist information about the subscription and monitored items. The session could also be persisted, but the subscriptions can be moved to new sessions as well, so it is not as important. Nevertheless, it is not currently possible to use the persisted information to reset the subscription and monitored items properly when the application starts up. We will need to play with this scenario a bit more.

The alternative way to get the missed events, also in the case that the subscription times out during the connection break, is to use event history in the server and query the missed events from the client when it starts up. This is what some customers have done to achieve this kind of robustness. But it requires that you can make the server store the event history, in the first place.

April 1, 2015
11:29, EEST
Avatar
BenC
Member
Members
Forum Posts: 6
Member Since:
April 1, 2015
sp_UserOfflineSmall Offline

OK, I’ll look into the event history functionality then.

I’ve read in the 1.5.0 server tutorial, §8, that the history manager only provides an API for an implementation, and that the SDK doesn’t provide an implementation out-of-the-box. Is this also the case in 2.1.0, or does that offer more related functionality than 1.5.0?

Thank you for the quick response!

April 1, 2015
12:02, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

The SDK does not provide an implementation, since it always requires a backend where you store the information.

But for testing, you can use the SampleConsoleServer, which includes a simple memory based history implementation.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
18 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: 731

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

inilarythikibia, rickykennion, PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466

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

Administrators: admin: 1