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
Client always reads value "2"
September 6, 2019
12:23, EEST
Forum Posts: 3
Member Since:
August 30, 2019
sp_UserOfflineSmall Offline


I’m trying to get a communication going between some hardware (OPC UA server) and a Java-based client. My end goal is writing data to the server.

I’ve managed to connect and read.
However, the client always reads value “2”. All the variables are initiated on 0 (or empty String).

To test my findings I also set up a localhost server (also all tags created, but values 0) and I got the same results.

I know that the values simply aren’t “2”, since I can easily verify using UaExpert.

Thanks in advance.

Input code:

UaClient client = new UaClient(“opc.tcp://localhost:48010”);
DataValue value = client.readAttribute(new NodeId(2, 6055), Attributes.NodeClass);
//client.writeAttribute(new NodeId(2, 6055), Attributes.NodeClass, 8.2654);

This is my output:

DataValue(value=2, statusCode=GOOD (0x00000000) “”, sourceTimestamp=null, sourcePicoseconds=0, serverTimestamp=09/06/19 09:15:37.7751737 GMT, serverPicoseconds=0)

September 6, 2019
13:43, EEST
Bjarne Boström
Forum Posts: 544
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline


You are reading the NodeClass Attribute as you pass the Attributes.NodeClass as parameter. That is technically an Enumeration type, and nodes that are Variables have NodeClass.Variable, which enumeration value equals to 2 (Enumerations are encoded as Int32 values). Therefore you will always “get 2”.

If you want to read the Value Attribute, you need to pass Attributes.Value (or just use the readValue convinience methods).

P.S. Technically all Read operations will result in DataValue objects regardless of the Attribute read, but typically grapchical clients wont show that data as typically only the Value Attribute changes over time, i.e. they only visualize the value part of the DataValue (or status if it is bad) for other Attributes.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online:
6 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: 1102

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1008

Posts: 4266

Newest Members:

normagalindo47, aurelia27u, isobel41d356980, michaeldegli, gqbdolores, kez1399, jaclynmcvay358, testuser20, edox, danilolapine

Moderators: Jouni Aro: 851, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 544, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 20, Markus Johansson: 19, Matti Siponen: 53, Lusetti: 0

Administrators: admin: 0