Please consider registering

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
read VS readValues ---> Not able to read multiple Data onDataChange without cached Values
July 1, 2020
10:38, EET
Ron Hoppe
New Member
Forum Posts: 1
Member Since:
July 1, 2020
sp_UserOfflineSmall Offline


I’m having trouble reading Data from the OPC UA Server. I have a subscription which gets triggered every minute and is supposed to
read Data from the OPC UA Server. For this action I tried to use the following two methods. (readValues(List) and readAttribute(NodeId, UnsignedInteger).

The first Method uses the Method “readValues” of the UaClient. This Methods reads alle the Values from all the Nodes I need at once and is very fast.
It is exactly what I need, but the is ONE BIG PROBLEM. If the Data I read every Minute changes, the “readValues” Method will not read the changed
new values und just reads the old values. It seems like this methods caches the old value in some way and just retruns me the old values instead of reading
the current values of the nodeId.

Because of this Issue I was forced to use the second Method “readAttribute” which uses the Method “read” of the UaClient. I have to call this Method for every single
Node I want to read the Value from. It does the job an gives me the current Values of the Node. The only problem here is that I now have a single reading request
for every Node and this slows down the reading quit a lot. In my case it takes about 10 times longer than the first Method.

It would be perfect beeing able to disable to caching for the “readValues” Method. This would give me the current Data of the Node in very little time. Please can
someone give me a hint how I can achive this 🙂

protected UaClient client;

public DataValue[] readValues(List nodeids){
NodeId[] nodes= new NodeId[nodeids.size()];
try {
DataValue[] values= client.readValues(nodeids.toArray(nodes));
return values;
} catch (Exception ex) {
return null;

public DataValue readAttribute(NodeId nodeId, UnsignedInteger attributeId){
ReadResponse response = null;
ReadValueId readValue = new ReadValueId(nodeId, attributeId, null, null);
try {
response= client.read(0.0, TimestampsToReturn.Both, readValue);
DataValue[] values = response.getResults();
return values[0];
} catch (Exception ex) {
return null;

July 1, 2020
15:12, EET
Matti Siponen

Forum Posts: 72
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline


I would first like to ask which version of the Prosys OPC UA SDK for Java you are using? In versions older than 3.2.0, the default value for maximum accepted age of the Value is non-zero, which means caching is used by default when reading Values from a Server. In newer versions, the default value is zero and thus caching isn’t used by default.

By calling UaClient.readValues(NodeId[] nodeIds, NumericRange[] indexRanges, TimestampsToReturn timestamps, Double maxCacheAge) instead of UaClient.readValues(NodeId[] nodeIds), you can use 0 as the value of maxCacheAge to request the Server to return the newest Value instead of a cached Value. You can set timestamps to TimestampsToReturn.Both and indexRanges to null.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online:
15 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 103

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 38

Rainer Versteeg: 32

Thomas Reuther: 31

Member Stats:

Guest Posters: 0

Members: 1160

Moderators: 15

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1048

Posts: 4416

Newest Members:

jonas.rahm, sophiekohler, zqecortney, adeletoscano947, forestgenders23, auroratrumper, ericmclain04, rblu, starlowery23194, dakotadalgety82

Moderators: Jouni Aro: 853, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 579, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Teppo Uimonen: 21, Markus Johansson: 24, Matti Siponen: 72, Lusetti: 0

Administrators: admin: 1