apache / plc4x

PLC4X The Industrial IoT adapter
https://plc4x.apache.org/
Apache License 2.0
1.24k stars 399 forks source link

[Bug]: OPCUA server and OPCUA failed to read data #1705

Open kdxq opened 1 month ago

kdxq commented 1 month ago

What happened?

uaExpert can read data,just like follow; image

I use opcua-server,config as follow: image

and the opcua server init. seems ok. image

and use opcua to read data from opcua-server, code as follow image

but the FanSpeed return Null image

what's wrong? @splatch please give me some suggest, waiting for your replay, thank you very much!

Version

v0.12.0

Programming Languages

Protocols

kdxq commented 1 month ago

I think the reson is in the opcua-server. I use 0.11.0, the opcua-server throw error as follow:

[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.context.SecureChannel - Active transaction Number 0
[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.context.SecureChannel - Active transaction Number 1
[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic - Decoding Message with Security policy None
[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.context.SecureChannel - Active transaction Number 2
[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic - Decoding Message with Security policy None
[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic - Public Key Length 1303
[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.context.SecureChannel - Active transaction Number 3
[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic - Decoding Message with Security policy None
[milo-shared-scheduled-executor-0] INFO org.apache.plc4x.java.opcua.context.SecureChannel - Active transaction Number 4
[milo-shared-scheduled-executor-0] WARN org.apache.plc4x.java.opcuaserver.backend.Plc4xCommunication - java.util.concurrent.TimeoutException Occurred while reading value, using timeout of 250ms
[nioEventLoopGroup-2-1] INFO org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic - Decoding Message with Security policy None
[nioEventLoopGroup-2-1] ERROR org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic - Read request ended up with ServiceFault:
╔═ExtensionObjectDefinition/ResponseHeader══════════════════════════════════════════════════════════════════════════╗
║╔═timestamp═══════════════════════════╗╔═requestHandle╗╔═serviceResult/StatusCode/statusCode═╗                     ║
║║0x01dad8202780b370 133656771574150000║║ 0x00000002 2 ║║        0x80270000 2150039552        ║                     ║
║╚═════════════════════════════════════╝╚══════════════╝╚═════════════════════════════════════╝                     ║
║╔═serviceDiagnostics/DiagnosticInfo═════════════════════════════════════════════════════════════╗╔═noOfStringTable╗║
║║╔═reserved╗╔═innerDiagnosticInfoSpecified╗╔═innerStatusCodeSpecified╗╔═additionalInfoSpecified╗║║  0x00000000 0  ║║
║║║b0 false ║║          b0 false           ║║        b0 false         ║║        b0 false        ║║╚════════════════╝║
║║╚═════════╝╚═════════════════════════════╝╚═════════════════════════╝╚════════════════════════╝║                  ║
║║╔═localeSpecified╗╔═localizedTextSpecified╗╔═namespaceURISpecified╗╔═symbolicIdSpecified╗      ║                  ║
║║║    b0 false    ║║       b0 false        ║║       b0 false       ║║      b0 false      ║      ║                  ║
║║╚════════════════╝╚═══════════════════════╝╚══════════════════════╝╚════════════════════╝      ║                  ║
║╚═══════════════════════════════════════════════════════════════════════════════════════════════╝                  ║
║╔═additionalHeader/ExtensionObject══════════════════════════════════════════════════════════════════╗              ║
║║╔═typeId/ExpandedNodeId═══════════════════════════════════════════════════════════════════════════╗║              ║
║║║╔═namespaceURISpecified╗╔═serverIndexSpecified╗╔═nodeId/NodeIdTypeDefinition════════════════════╗║║              ║
║║║║       b0 false       ║║      b0 false       ║║╔═nodeType/NodeIdType═══╗╔═NodeIdTwoByte═══════╗║║║              ║
║║║╚══════════════════════╝╚═════════════════════╝║║0x0 0 nodeIdTypeTwoByte║║╔═id═══╗╭┄identifier╮║║║║              ║
║║║                                               ║╚═══════════════════════╝║║0x00 0║┆     0     ┆║║║║              ║
║║║                                               ║                         ║╚══════╝╰┄┄┄┄┄┄┄┄┄┄┄╯║║║║              ║
║║║                                               ║                         ╚═════════════════════╝║║║              ║
║║║                                               ╚════════════════════════════════════════════════╝║║              ║
║║║╭┄identifier╮                                                                                    ║║              ║
║║║┆     0     ┆                                                                                    ║║              ║
║║║╰┄┄┄┄┄┄┄┄┄┄┄╯                                                                                    ║║              ║
║║╚═════════════════════════════════════════════════════════════════════════════════════════════════╝║              ║
║║╔═encodingMask/ExtensionObjectEncodingMask═══════════╗╭┄identifier╮                                ║              ║
║║║╔═reserved╗╔═typeIdSpecified╗╔═xmlbody╗╔═binaryBody╗║┆     0     ┆                                ║              ║
║║║║  0x0 0  ║║    b0 false    ║║b0 false║║ b0 false  ║║╰┄┄┄┄┄┄┄┄┄┄┄╯                                ║              ║
║║║╚═════════╝╚════════════════╝╚════════╝╚═══════════╝║                                             ║              ║
║║╚════════════════════════════════════════════════════╝                                             ║              ║
║╚═══════════════════════════════════════════════════════════════════════════════════════════════════╝              ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

0.12.0, the opcua-server throw error as follow: image

splatch commented 1 month ago

The incompatible datatype exception means that value you expect to be a float is encoded differently. Try first switching getFloat to getObject to determine how it is being transmitted. Second step - with 0.12 you can also specify read value type in opc ua tag address.

kdxq commented 1 month ago

add data type,but still get value none. image

I used plc4x-opcua-server as server, and used ua_export as client. when I add the url to ua_export client pop error as follow: image then, I ignore it, ua_export show the data structure as follow: image and get data in loop, error as follow image

kdxq commented 1 month ago

image

0.11.0 version,eip part got values , but opcua part still error。

splatch commented 1 month ago

@kdxq Can you try ns=1;s=FanSpeed;REAL syntax for OPC UA tags?

kdxq commented 1 month ago

@splatch do you mean like this? still failed image

kdxq commented 1 month ago

by the way. when I write data. only float type is ok, all others type all failed.as follow

image

image

kdxq commented 1 month ago

@splatch did you mean like this? still failed image

kdxq commented 1 month ago

Hi,@ottlukas ,@splatch,I have tested the opcu ua server from 0.10.0 to 0.13.0, but none of them were able to read data, and none of the data types worked. Do you have any other testing suggestions? Additionally, the testing sources for the OPCUA I am using are publicly available online (https://github.com/node-opcua/node-opcua/wiki/publicly-available-OPC-UA-Servers-and-Clients). Can you provide some guidance on how to conduct the testing,Or publish a config. xml file that you believe can correctly read and write data related to OPC UA configuration? I want to make plc4x better and more stable.

splatch commented 1 month ago

@kdxq I’m going to work on some integration tests which will need working opc ua server. I’ll try to pull this issue as part of test setup. I’ll work on plc4j from 1st August.

splatch commented 4 weeks ago

@kdxq I've had a look on behavior of starfive demo server and there is something odd in there. I could not fully reproduce your issue. To be fair, I could not connect to demo server at all with 0.13-SNAPSHOT. Interestingly, local instance of node-opcua do not have this issue.

I've found that with 0.13 anonymous authentication differs between clients. We do not supply client nonce nor certificate for create session request if security mode is NONE. I'll try to fix connectivity issue first and then see if readout issue still remains.

qtvbwfn commented 3 weeks ago

I connected to your service and, based on the tool's view, the data type should be Double, not Float.

image

qtvbwfn commented 3 weeks ago

@kdxq I connected to your service and, based on the tool's view, the data type should be Double, not Float.

image