Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 16 tasks
kdxq opened this issue Jul 17, 2024 · 13 comments · Fixed by #1830
Closed
2 of 16 tasks

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

kdxq opened this issue Jul 17, 2024 · 13 comments · Fixed by #1830
Assignees
Labels
bug java Pull requests that update Java code OPC-UA https://plc4x.apache.org/users/protocols/opcua.html

Comments

@kdxq
Copy link

kdxq commented Jul 17, 2024

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

  • plc4j
  • plc4go
  • plc4c
  • plc4net

Protocols

  • AB-Ethernet
  • ADS /AMS
  • BACnet/IP
  • CANopen
  • DeltaV
  • DF1
  • EtherNet/IP
  • Firmata
  • KNXnet/IP
  • Modbus
  • OPC-UA
  • S7
@kdxq kdxq added the bug label Jul 17, 2024
@kdxq
Copy link
Author

kdxq commented Jul 17, 2024

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
Copy link
Contributor

splatch commented Jul 17, 2024

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
Copy link
Author

kdxq commented Jul 17, 2024

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
Copy link
Author

kdxq commented Jul 17, 2024

image

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

@splatch
Copy link
Contributor

splatch commented Jul 17, 2024

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

@kdxq
Copy link
Author

kdxq commented Jul 17, 2024

@splatch do you mean like this? still failed
image

@kdxq
Copy link
Author

kdxq commented Jul 17, 2024

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

image

image

@kdxq
Copy link
Author

kdxq commented Jul 18, 2024

@splatch did you mean like this? still failed
image

@ottlukas ottlukas added java Pull requests that update Java code OPC-UA https://plc4x.apache.org/users/protocols/opcua.html labels Jul 19, 2024
@kdxq
Copy link
Author

kdxq commented Jul 23, 2024

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
Copy link
Contributor

splatch commented Jul 23, 2024

@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
Copy link
Contributor

splatch commented Aug 8, 2024

@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.

@splatch splatch self-assigned this Aug 8, 2024
@qtvbwfn
Copy link
Contributor

qtvbwfn commented Aug 10, 2024

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

image

splatch added a commit that referenced this issue Oct 17, 2024
Amended selection logic made use of streams with side effects.
When server had more than one endpoint and these endpoints had same policy (i.e. anonymous) with different identifiers (i.e. anonymous_1, anonymous_2), it lead to wrong activate session requests which mixed endpoint and user token policy.
Updated logic removes side effects and makes sure that only policies of matched server endpoint are tested against client configuration.

Closes #1705.

Signed-off-by: Łukasz Dywicki <[email protected]>
splatch added a commit that referenced this issue Oct 17, 2024
Amended selection logic made use of streams with side effects.
When server had more than one endpoint and these endpoints had same policy (i.e. anonymous) with different identifiers (i.e. anonymous_1, anonymous_2), it lead to wrong activate session requests which mixed endpoint and user token policy.
Updated logic removes side effects and makes sure that only policies of matched server endpoint are tested against client configuration.

Closes #1705.

Signed-off-by: Łukasz Dywicki <[email protected]>
@splatch
Copy link
Contributor

splatch commented Oct 17, 2024

@kdxq I've pushed a fix which fixed compatibility issue with demo server from starfive / node-opcua. Please test current develop and re-open this issue in case if bug you spotted still remains.

The timeout errors you was getting was likely caused by client not really connecting to demo server, and so making it impossible to fetch tag value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug java Pull requests that update Java code OPC-UA https://plc4x.apache.org/users/protocols/opcua.html
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants