plc4x-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Strljic, Matthias Milan" <matthias.strl...@isw.uni-stuttgart.de>
Subject AW: OPC UA communication
Date Mon, 04 May 2020 08:12:48 GMT
Hi Titus,


Nice to hear that it was just a small fix required in the setup 😊

Could you describe the problem that you had, to avoid it for up comming users?


The accessLevel is a security feature of OPC UA which is only configurable over the server
configuration or with an admin level user.

So for that you have to contact the server admins. Else you could check with tools like UAExplorer
or something similiar the accessLevel of the item.

Because there was a bug in the past where we did a mistake in the write configuration which
should be fixed.


I hope that helps a bit.


Best regards
Matthias

________________________________
Von: Titus Hartmann <titus.hartmann1@gmail.com>
Gesendet: Montag, 4. Mai 2020 08:29:34
An: dev@plc4x.apache.org
Betreff: Re: OPC UA communication

Hello Matthias,

Looks like it was again just an error with missing JARs. Reading works
and with writing the access is currently denied. Do you guys have a
way to change this accessLevel over the API or do I have to do it on
the server itself?

Thanks!
Titus

Am Sa., 2. Mai 2020 um 11:28 Uhr schrieb Titus Hartmann
<titus.hartmann1@gmail.com>:
>
> Hello Matthias,
>
>
> thank you for the response!
>
>
> I tryied with the latest version of Milo 0.4.1 but I got an error with that:
>
>
> [main] INFO org.apache.plc4x.java.PlcDriverManager - Instantiating new
> PLC Driver Manager with class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@c387f44
>
> [main] INFO org.apache.plc4x.java.PlcDriverManager - Registering
> available drivers...
>
> [main] INFO org.apache.plc4x.java.PlcDriverManager - Registering
> driver for Protocol opcua (OPC UA (TCP))
>
> [main] INFO org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection
> - Configured OpcuaTcpPlcConnection with: host-name 127.0.0.1
>
> [NonceUtilSecureRandom] INFO
> org.eclipse.milo.opcua.stack.core.util.NonceUtil - SecureRandom seeded
> in 1ms.
>
> [main] INFO org.eclipse.milo.opcua.sdk.client.OpcUaClient - Eclipse
> Milo OPC UA Stack version: 0.4.0
>
> [main] INFO org.eclipse.milo.opcua.sdk.client.OpcUaClient - Eclipse
> Milo OPC UA Client SDK version: 0.4.0
>
> [main] INFO org.titus.plc4x.OpcReader - Verbindung ist aufgebaut...
>
> [main] INFO org.titus.plc4x.OpcReader - Anfrage gesendet...
>
> [main] ERROR org.titus.plc4x.OpcReader - Konnte keine Verbindung aufbauen
>
> java.util.concurrent.ExecutionException: java.lang.ClassCastException:
> class org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId
> cannot be cast to class
> org.eclipse.milo.opcua.stack.core.types.builtin.NodeId
> (org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId and
> org.eclipse.milo.opcua.stack.core.types.builtin.NodeId are in unnamed
> module of loader 'app')
>
>              at
> java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
>
>              at
> java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2070)
>
>              at org.titus.plc4x.OpcReader.main(OpcReader.java:29)
>
> Caused by: java.lang.ClassCastException: class
> org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId cannot
> be cast to class
> org.eclipse.milo.opcua.stack.core.types.builtin.NodeId
> (org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId and
> org.eclipse.milo.opcua.stack.core.types.builtin.NodeId are in unnamed
> module of loader 'app')
>
>              at
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.encodeFieldItem(OpcuaTcpPlcConnection.java:115)
>
>              at
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$read$8(OpcuaTcpPlcConnection.java:404)
>
>              at
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1771)
>
>              at
> java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1763)
>
>              at
> java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
>
>              at
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
>
>              at
> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
>
>              at
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
>
>              at
> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
>
>
>
> After Debugging I found out that it was a Problem with the Version so
> I used Milo 0.3.6 and the Problem with the Connection was gone. But
> another error appeared:
>
>
> [main] INFO org.apache.plc4x.java.PlcDriverManager - Instantiating new
> PLC Driver Manager with class loader
> jdk.internal.loader.ClassLoaders$AppClassLoader@c387f44
>
> [main] INFO org.apache.plc4x.java.PlcDriverManager - Registering
> available drivers...
>
> [main] INFO org.apache.plc4x.java.PlcDriverManager - Registering
> driver for Protocol opcua (OPC UA (TCP))
>
> [main] INFO org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection
> - Configured OpcuaTcpPlcConnection with: host-name 127.0.0.1
>
> [NonceUtilSecureRandom] INFO
> org.eclipse.milo.opcua.stack.core.util.NonceUtil - SecureRandom seeded
> in 1ms.
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/milo/opcua/binaryschema/parser/BsdParser
>
>              at
> org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig.builder(OpcUaClientConfig.java:96)
>
>              at
> org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.connect(OpcuaTcpPlcConnection.java:242)
>
>              at
> org.apache.plc4x.java.PlcDriverManager.getConnection(PlcDriverManager.java:73)
>
>              at org.titus.plc4x.OpcReader.main(OpcReader.java:18)
>
> Caused by: java.lang.ClassNotFoundException:
> org.eclipse.milo.opcua.binaryschema.parser.BsdParser
>
>              at
> java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
>
>              at
> java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
>
>              at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
>
>              ... 4 more
>
>
>
> My Code is as follows (but the error is the same with the
> ManualPLC4XOpcua Code):
>
>
> public class OpcReader {
>
>              private static final Logger logger =
> LoggerFactory.getLogger(OpcReader.class);
>
>              public static void main(String[] args) {
>
>                            try ( OpcuaTcpPlcConnection opcuaConnection
> = (OpcuaTcpPlcConnection) new
> PlcDriverManager().getConnection("opcua:tcp://localhost:5801/OPC_Simulation_Server?discovery=false"))
> {
>
>                                         logger.info("Verbindung ist
> aufgebaut...");
>
>                                         PlcReadRequest.Builder
> readBuilder = opcuaConnection.readRequestBuilder();
>
>                                         readBuilder.addItem("Menge",
> "ns=2;i=4");
>
>
>                                         PlcReadRequest request =
> readBuilder.build();
>
>                                         logger.info("Anfrage gesendet...");
>
>             PlcReadResponse response = opcuaConnection.read(request).get();
>
>                                         logger.info("Antwort der Steuerung:");
>
>                                         for (String fieldName :
> response.getFieldNames()) {
>
>                                                      logger.info("{} -
> {}", fieldName, response.getResponseCode(fieldName));
>
>                                                      if
> (response.getResponseCode(fieldName) == PlcResponseCode.OK) {
>
>
> logger.info("{} - {}", fieldName, response.getObject(fieldName));
>
>                                                      }
>
>                                         }
>
>                            } catch (Exception e) {
>
>                                         logger.error("Konnte keine
> Verbindung aufbauen", e);
>
>                            }
>
>              }
>
> }
>
>
>
> As a OPC Server I use a Python tool called FreeOpcUa
> (https://github.com/FreeOpcUa/python-opcua) and just simply set up
> some variables with:
>
>
> from opcua import Server
>
> server = Server()
>
> url = "opc.tcp://localhost:5801"
>
> server.set_endpoint(url)
>
> name = "OPC_Simulation_Server"
>
> addspace = server.register_namespace(name)
> node = server.get_objects_node()
> Param = node.add_object(addspace, "Parameters")
> ANr = Param.add_variable(addspace, "Auftragsnummer", 0)
> Stk = Param.add_variable(addspace, "Stückzahl", 0)
> Menge = Param.add_variable(addspace, "Menge", 0)
> ANr.set_writable()
> Stk.set_writable()
> Menge.set_writable()
> server.start()
>
> print("Server started at {}".format(url))
>
>
> Thank you for your help and advice.
>
> Greets
>
> Titus
>
> Am Do., 30. Apr. 2020 um 23:33 Uhr schrieb Strljic, Matthias Milan
> <matthias.strljic@isw.uni-stuttgart.de>:
> >
> > Hello Titus,
> >
> >
> > the driver supports read, write and subscribe. So you should be able to write values
to an OPC UA server.
> >
> > If you could provide there some meta data to your issue we can perhaps help you
with that?
> >
> > What kind of node type you try to read/write?
> >
> >
> > The ManualPLC4XOpcua test class includes for all request types some small examples.
> >
> > URL to ManualPLC4XOpcua: https://github.com/apache/plc4x/blob/rel/0.6/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java
> >
> >
> > To achieve the best results you could build the latest version of the 0.6 branch
and use that until we publish the 0.6.1 release candidate.
> >
> >
> > Best regards
> >
> > Matthias
> >
> > ________________________________
> > Von: Titus Hartmann <titus.hartmann1@gmail.com>
> > Gesendet: Donnerstag, 30. April 2020 10:01:27
> > An: dev@plc4x.apache.org
> > Betreff: Re: OPC UA communication
> >
> > Hello Matthias,
> >
> > thank you for your response! Is there any Option to get around this so
> > that I can read some nodes for test cases?
> > The other question that comes to my mind is if there is a write
> > methode like the one in the S7 Adapter already implemented? Or is
> > there help needed?
> >
> > I started my program this morning and there was another error present.
> > Could you help me out with this aswell?
> >
> > java.util.concurrent.ExecutionException: java.lang.ClassCastException:
> > class org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId
> > cannot be cast to class
> > org.eclipse.milo.opcua.stack.core.types.builtin.NodeId
> > (org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId and
> > org.eclipse.milo.opcua.stack.core.types.builtin.NodeId are in unnamed
> > module of loader 'app')
> >  at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
> >  at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2070)
> >  at org.titus.plc4x.OpcReader.main(OpcReader.java:44)
> > Caused by: java.lang.ClassCastException: class
> > org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId cannot
> > be cast to class
> > org.eclipse.milo.opcua.stack.core.types.builtin.NodeId
> > (org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId and
> > org.eclipse.milo.opcua.stack.core.types.builtin.NodeId are in unnamed
> > module of loader 'app')
> >  at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.encodeFieldItem(OpcuaTcpPlcConnection.java:115)
> >  at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.lambda$read$8(OpcuaTcpPlcConnection.java:404)
> >  at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1771)
> >  at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1763)
> >  at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> >  at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
> >  at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
> >  at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
> >  at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
> >
> > Thank you and greets
> > Titus
> >
> > Am Do., 30. Apr. 2020 um 09:35 Uhr schrieb Strljic, Matthias Milan
> > <matthias.strljic@isw.uni-stuttgart.de>:
> > >
> > > Hello, Titus,
> > >
> > > the discovery part is an optional parameter. By default the opc ua driver uses
the discovery endpoint of an opc ua server to get the correct endpoint description.
> > > If the parameter is set to false, it ignores this discovery result and forces
the specified ip + port combination. We had to implement this option because opc ua servers
do not always seem to be configured correctly.
> > > But you are right, the documentation part is missing there. We will address
this soon to avoid these ambiguities.
> > >
> > >
> > > The bug you mentioned is already fixed in the upcoming versions 7.0 and 6.1
and should be released soon.
> > >
> > > Greetings
> > > Matthias
> > >
> > >
> > > ________________________________
> > > Von: Titus Hartmann <titus.hartmann1@gmail.com>
> > > Gesendet: Mittwoch, 29. April 2020 14:57:35
> > > An: dev@plc4x.apache.org
> > > Betreff: OPC UA communication
> > >
> > > Hello everyone,
> > >
> > > following the mail addressed to Julian I have a Question regarding the
> > > communication between Prosys OPC UA and PLC4X.
> > >
> > > In the demo Julian used in his Webinar there is this Connection String:
> > >
> > > "opcua:tcp://10.8.0.2:53530/opcua/SimulationServer?discovery=false&username=tester&password=test1234"
> > >
> > > I’m wondering what the discovery part does. Can you help me with this?
> > > Using this Code the following error appeared:
> > >
> > > org.apache.plc4x.java.api.exceptions.PlcConnectionException: Unable to
> > > discover URL:opc.tcp://192.168.222.27:53530/OPCUA/SimulationServer?discovery=false/discovery
> > >
> > >        at org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection.connect(OpcuaTcpPlcConnection.java:187)
> > >
> > >        at org.apache.plc4x.java.PlcDriverManager.getConnection(PlcDriverManager.java:73)
> > >
> > >        at org.titus.plc4x.OpcReader.main(OpcReader.java:48)
> > >
> > > After Debugging I noticed that the URL is not correctly separated.
> > > Thats why the discovery part is ignored. Not sure why it worked in the
> > > demo though.
> > >
> > > Do you guys have any idea how I could fix this?
> > >
> > > Thanks and best regards
> > >
> > > Titus
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message