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: 1010
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: 1010
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: 518

Currently Online:
12 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 682

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1