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 activate auditing
February 21, 2018
1:04, EET
Avatar
Mike.Stair
Member
Members
Forum Posts: 12
Member Since:
January 12, 2018
sp_UserOfflineSmall Offline

Hi,
I would like to create a log with all the events that happen on the server.
I have read in the OPC-UA specifications that the auditing service could be useful.

How can I activate auditing events?
how can I intercept them? with the Interface EventListener?

Regards,
Mike

February 21, 2018
10:44, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello Mike,

Unfortunately there’s currently no functionality in the Prosys OPC UA Java SDK to specifically help with handling of the auditing events.

That being said, we’re not aware of any auditing functionality that you couldn’t add on top of the current implementation. So your own application should be able to implement the auditing functionality if you need to implement this. If you’re interested in some specific auditing feature, please send us an explanation of the exact requirements and we’ll be happy to offer some advice on how to implement the functionality with the SDK.

February 26, 2018
12:26, EET
Avatar
Mike.Stair
Member
Members
Forum Posts: 12
Member Since:
January 12, 2018
sp_UserOfflineSmall Offline

Hello Heikki,

I would trap all requests from clients that arrive at the server and create a log file of requests. In a second time I would like to simulate all the recorded sequence.

could I use log properties (log4j.properties) to register requests?

Are there server-side primitives that create / simulate requests coming from the client without instantiating it?

Thanks for your help

February 26, 2018
14:37, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

You can log all request/response pairs that the SDK part handles by implementing a RequestResponseListener and setting it to the UaServer:

server.getAttributeServiceHandler().setRequestResponseListener(listener);
server.getSessionServiceHandler().setRequestResponseListener(listener);
server.getSubscriptionServiceHandler().setRequestResponseListener(listener);
server.getNodeManagementServiceHandler().setRequestResponseListener(listener);

Note that it will not log the lower-level messages handled by the stack layer, so in general you will see requests for the CreateSession and afterwards. These are also the same that can be logged in our SimulationServer Req/Res Log view (the feature was done for this use-case). However simulating these a second time is not in practice possible.

In general it is not possible or practical to simulate the client in the server side. Currently it is easier to just create a local client and use it to send the requests.

– Bjarne

February 27, 2018
15:05, EET
Avatar
Mike.Stair
Member
Members
Forum Posts: 12
Member Since:
January 12, 2018
sp_UserOfflineSmall Offline

Hi Bjarne,

my purpose would be to debug at the application level. In order to do this, requests coming to the server (for example read / write requests) should be traceable and repeatable in a deteministic manner.

The order of the read / write requests that can be managed through the listeners (example I / O ManagerListener) is the same as seen at the opc-ua stack level?
In other words, the order of requests arriving at the server from a client or from multiple clients may be different from those managed by listeners?

Could I use the I / O Manager Listener instead of the ReqResponseListener? It intercepts the request before sending the reply

Thanks for your help
Mike

February 27, 2018
16:32, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Unless you have exactly one client that sends exactly one request at a time and waits for the response before sending the next one, it is not possible to deterministically determine the order on the network level (i.e. no guarantee that they would be in the same order the next time). Therefore the order in which the stack layer receives them is random. Then the stack layer handles each request in a blocking-work-thread-pool and after they have been submitted to the pool the order of thread execution is also random (this is normal Java). Also in general Java Threads can pause and start at any time, therefore even if you would log them before they would be handled, nothing guarantees that the execution order between them has not changed on the next line of code (this is normal Java).

In theory the pool size could be one, but then the server would not be able to serve more than one request at a time (which would not be expected performance). However in practice the stack internals use the pool quite often so setting it to one could lead to an internal deadlock.

If you have exactly one client that sends exactly one request at a time and waits for the response before sending new one, then the scenario is different as the server only has one request to handle at a time (multiple clients case would also work, if there is only one request in total from all of them at any given time). However a real client application usually does not do this, e.g. most of the clients do actively monitor or read the server status in order to determine is the server up or to check if the status changes to shutdown, also it keeps the connection from timeouting. Even for a special client that would not do this, you would need to store all session related info and somehow put it back in a simulation as OPC UA is session based protocol, i.e. it is stateful.

– Bjarne

February 28, 2018
16:19, EET
Avatar
Mike.Stair
Member
Members
Forum Posts: 12
Member Since:
January 12, 2018
sp_UserOfflineSmall Offline

Hi Bjarne,

Thank you so much for your help!

About this I have a question:

server.getAttributeServiceHandler().setRequestResponseListener(listener);

How can I get the following information from the RequestResponse listener for read and write requests?
– type of request
– client identification information
– node id
– attribute id
– read or written values of an attribute

public class MyRequestResponseListener implements RequestResponseListener{

@Override
public void onRequestResponse(ServiceRequest request, ServiceResponse response) {

// How to get the information listed above?
System.out.println(response);

}
}

Regards,
Mike

March 1, 2018
17:27, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

You can cast the request/responses e.g. to ReadRequest/Response (if you add the same listener to other XXXServiceHandlers, you need to check that they are of correct type first), and then use getters of the casted one.

– Bjarne

March 11, 2018
20:22, EET
Avatar
Luke.d
Member
Members
Forum Posts: 8
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline

Heikki Tahvanainen said
Hello Mike,

Unfortunately there’s currently no functionality in the Prosys OPC UA Java SDK to specifically help with handling of the auditing events.

That being said, we’re not aware of any auditing functionality that you couldn’t add on top of the current implementation. So your own application should be able to implement the auditing functionality if you need to implement this. If you’re interested in some specific auditing feature, please send us an explanation of the exact requirements and we’ll be happy to offer some advice on how to implement the functionality with the SDK.  

Hi,
I too would interested to auditing functionality.
In particular, I would like to trace the requests (and possibly also the responses) of reading and writing services.

As a first test, I used a IoManagerListener and I override methods OnRead() and OnWrite().
These methods send events of type “AuditEventType” (or a its subtype) using triggerEvent(..);
If i’m not mistaken, in these events, I can insert the data variable or property that interest me to tracing request.
Then, these events are handled in a EventListener in the method onEvent((UaNode u, EventData e));
In onEvent(..) I trace these requests.

Can it be a correct procedure or not?
Is it necessary to perform other operations? (For example set the standard variable (property) flag indicating whether the server is currently generating audit events, and check it if set up for sending AuditEvent)

For tracing purpose, i also used s reqResponseListener and it works fine, but i’m interested to using auditing.

Thanks in advance,
Regards,
Luke

March 12, 2018
11:53, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi Luke,

In general the question is do you mean:
1. The OPC UA Auditing system as whole described in the specification (multiple places, but main concept is explained in v.1.03 Part 2 section 4.12.1)
2. Just recording all Read and Write request/responses?

Note that if you send events, then all clients that are able to make subscriptions with an EventFilter for the Properties of the Audit types will receive those events/data. Currently it is not possible to limit sending event to only a specific session, however you can add a SubscriptionManagerListener which forbids non-admin users to make EventFilters that contain fields for the audit Properties.

For AuditWriteUpdateEvents that would most likely be the correct procedure. OPC UA as of 1.03 seems to contain about 40 different Audit event types so that is the implementation of one of them.

In general if you want to make complete support for the audit system, you need to read the specification for all the details and follow them, including the Objects/Server/Auditing property.

– Bjarne

March 12, 2018
18:22, EET
Avatar
Luke.d
Member
Members
Forum Posts: 8
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline

Bjarne Boström said
Hi Luke,

In general the question is do you mean:
1. The OPC UA Auditing system as whole described in the specification (multiple places, but main concept is explained in v.1.03 Part 2 section 4.12.1)
2. Just recording all Read and Write request/responses?

Note that if you send events, then all clients that are able to make subscriptions with an EventFilter for the Properties of the Audit types will receive those events/data. Currently it is not possible to limit sending event to only a specific session, however you can add a SubscriptionManagerListener which forbids non-admin users to make EventFilters that contain fields for the audit Properties.

For AuditWriteUpdateEvents that would most likely be the correct procedure. OPC UA as of 1.03 seems to contain about 40 different Audit event types so that is the implementation of one of them.

In general if you want to make complete support for the audit system, you need to read the specification for all the details and follow them, including the Objects/Server/Auditing property.

– Bjarne  

Hi Bjarne,
Thanks for you time,

Yes, that’s quite what I mean.
So, for “Write request” I will use AuditWriteUpdateEvents but for “read request”?
I have not found a Audit type for read request (in the specification); for that, can I use “AuditEventType”?

Thanks again,
regards,
Luke

March 13, 2018
17:05, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

The specification v1.03 Part 4 section 6.3.8 for Auditing for Attribute Service Set mentions that:
“The Read and HistoryRead Services may generate audit entries and audit Events for failed Service invocations. These Services should generate an audit Event of type AuditEventType or a subtype of it. See Part 5 for the detailed assignment of the SourceNode, SourceName and additional parameters. The Message for Events of this type should include a description of why the Service failed.”

Therefore in the scope of the Auditing system (the 1. option in my prev answer) only failed service calls will be sent as events. In practical sense reads do not modify the state of the server and most clients do read the server status node periodically (e.g. once per second), therefore events for read operations would create a lot of events, which most likely is the reason there is no event for reads.

– Bjarne

March 13, 2018
17:59, EET
Avatar
Luke.d
Member
Members
Forum Posts: 8
Member Since:
February 21, 2018
sp_UserOfflineSmall Offline

Bjarne Boström said
The specification v1.03 Part 4 section 6.3.8 for Auditing for Attribute Service Set mentions that:
“The Read and HistoryRead Services may generate audit entries and audit Events for failed Service invocations. These Services should generate an audit Event of type AuditEventType or a subtype of it. See Part 5 for the detailed assignment of the SourceNode, SourceName and additional parameters. The Message for Events of this type should include a description of why the Service failed.”

Therefore in the scope of the Auditing system (the 1. option in my prev answer) only failed service calls will be sent as events. In practical sense reads do not modify the state of the server and most clients do read the server status node periodically (e.g. once per second), therefore events for read operations would create a lot of events, which most likely is the reason there is no event for reads.

– Bjarne  

It’s everything clear.

Thanks a lot.
Best Regards

– Luke

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
23 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: 729

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala

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

Administrators: admin: 1