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
How to test sending and receiving an event with sample server/client?
July 30, 2014
12:34, EEST
Avatar
Allan
Member
Members
Forum Posts: 11
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

In the sample server, you can type ‘e’ to send an event.
But how can you get to the point where the sample client prints out the event in a log message?
I tried the subscription menu item with various nodes selected, but didn’t see any log output.

By the way, I noticed a null pointer exception while trying to do this.
It seems that a call to ‘ initEventFieldNames()’ is missing in ‘createMonitoredEventItem(NodeId nodeId)’,
so that the last two items in the ‘eventFieldNames’ array remain null.

Thanks

July 31, 2014
10:09, EEST
Avatar
Otso Palonen
Espoo, Finland
Moderator
Moderators
Forum Posts: 32
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Hi Allan,

It seems that this in an error in the SampleConsoleServer. We will fix the issue shortly.

August 4, 2014
15:17, EEST
Avatar
Allan
Member
Members
Forum Posts: 11
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

I am using code similar to the sample server’s MyNodeManager.sendEvent() method to send events, but can’t seem to receive any events in the client.
The client code calls “subscribe(myVariableId, Attributes.EventNotifier)”, where the subscribe() method is based on the one in SampleConsoleClient.
The event is based on the MyEventType class.

I noticed that the createAlarmNode() method in the sample server has these calls (which my code doesn’t have yet, since I didn’t add alarms yet):

source.addReference(myAlarm, Identifiers.HasCondition, false);
myDevice.addReference(source, Identifiers.HasEventSource, false);
myObjectsFolder.addReference(myDevice, Identifiers.HasNotifier, false);

Do I need to make similar calls to register the event?

Please let me know when there is a fixed version of the sample code where the ‘e’ command for sending events works, so I can see how it is done there.

Thanks!

August 11, 2014
13:07, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

You don’t need to add the references to basic events. However, you can use the Source property to define to which object the event should be sent. By default, this should be the Server object, though so it should work by default.

Note that events are only available for objects, not for variables.

August 11, 2014
13:30, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

BTW: ‘initEventFieldNames()’ call is in the ‘createMonitoredEventItem()’ of the SampleConsoleClient. Are you sure, you have the original version?

August 11, 2014
13:31, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

And to clarify: you can always listen to the Server object to get all events from the server.

August 12, 2014
11:04, EEST
Avatar
Allan
Member
Members
Forum Posts: 11
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

> BTW: ‘initEventFieldNames()’ call is in the ‘createMonitoredEventItem()’ of the SampleConsoleClient. Are you sure, you have the original version?

You are right. I must have accidentally deleted that line.

> And to clarify: you can always listen to the Server object to get all events from the server.

So you would call (in the sample client):
subscribe(Identifiers.RootFolder, Attributes.EventNotifier);
?

That didn’t work for me (I did modify the event filter to leave out the “where” clause).
At least my SubscriptionNotificationListener.onEvent() method was never called.

August 12, 2014
11:24, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1010
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Allan said

So you would call (in the sample client):
subscribe(Identifiers.RootFolder, Attributes.EventNotifier);
?

No: Identifiers.Server is the correct one.

July 17, 2015
11:36, EEST
Avatar
Reshu
New Member
Members
Forum Posts: 1
Member Since:
July 16, 2015
sp_UserOfflineSmall Offline

Hi,

I was also trying to setup events bewteen server and client.
I have a folder in which the objects of my Information Model are placed. EventNotifier for this folder is set to SubscribeToEvents.

When I try to subscribe this folder from client with attributeId=12 i.e. EventNotifier, I get and exception:

07/17/2015 16:57:25.153 DEBUG [Blocking-Work-Executor-2] com.prosysopc.ua.client.UaClient – handlePublishResponse: response=1
07/17/2015 16:57:25.153 DEBUG [PublishTask-com.prosysopc.ua.client.UaClient@15bf497] com.prosysopc.ua.client.nodes.UaNodeImpl – getProperty: name=MaxNodesPerRead
07/17/2015 16:57:25.153 DEBUG [Blocking-Work-Executor-2] com.prosysopc.ua.client.UaClient$a – ServiceException:
com.prosysopc.ua.ServiceException ServiceResult=BAD (0x80000000) “” Diagnostics=Diagnostic Info:

at com.prosysopc.ua.client.UaClient.a(Unknown Source)
at com.prosysopc.ua.client.UaClient.a(Unknown Source)
at com.prosysopc.ua.client.UaClient$a.onCompleted(Unknown Source)
at org.opcfoundation.ua.transport.impl.AsyncResultImpl$2.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I guess because of this exception my subscription is not created correctly and I am not able to receive events on Client.

Please provide guidance.

Thanks

July 17, 2015
12:53, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

The exception happens because the ServiceResult statuscode of the PublishResponse is Bad, therefore we do not process it.

Weird is that the returned status code is just a plain BAD instead of more precise error code, therefore it is a bit hard to say what the actual problem is.

Which server you are connecting to? Also in case it might be relevant, which SDK version you are using?

There is no diagnostics info returned, so either server did not return anything or diagnostics are off. Check Root/Objects/Server/ServerDiagnostics/EnabledFlag and write it to be true (or maybe there is option to turn it on in server configuration).

Is there anything in the server logs while this happens?

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
13 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: 683

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