FraunhoferIOSB / FAAAST-Service

FA³ST - Fraunhofer Advanced Asset Administration Shell Tools (for Digital Twins)
Other
57 stars 11 forks source link

Problem with Operation Provider for OPC UA #896

Closed sunshineRunner22 closed 2 weeks ago

sunshineRunner22 commented 3 weeks ago

I have a test OPC UA server and a test AAS model and I'm trying to set up an Operation Provider for OPC UA. Value and Subscription Provider are working fine. Inside the AAS I have a "TestOperation"-operation with a string-input, on the OPC UA server I have a methode calles "TestOperation" with a string-InputArgument. This is my config.json with the code to set up the Operation Provider:

{ "assetConnections": [ { "@class": "de.fraunhofer.iosb.ilt.faaast.service.assetconnection.opcua.OpcUaAssetConnection", "host": "opc.tcp://localhost:48010", "operationProviders": { "[ModelRef](Submodel)https://example.org/submodel/1, (Operation)TestOperation": { "nodeId": "ns=2;i=2" } } } ] }

When starting FA³ST service, I first get the message "Establishing asset connection failed on initial attempt...". Afterwards the whole service seems to crash. Please see the screenshots below. What am I missing?

1 2

fvolz commented 3 weeks ago

Hi, it seems like the OPC UA arguments do not have names. It may seem like they are called "InputArguments", but there can be multiple arguments which all have distinct names. They should be identical to the idShort in the arguments of the Operation, otherwise argumentMapping is necessary: "inputArgumentMapping": [ { "idShort": "in1", "argumentName": "Input1" }, { "idShort": "in2", "argumentName": "Input2" } ],

Compare with our named arguments: image

For futher debugging, can you provide me your model.aasx ? If you can provide the nodeset.xml, I could also try to write a working configuration file, however, I think the OPC Arguments need names for the configuration to work. We will try to better catch the error on name mismatch. In the meantime, can you try to rename the OPC UA arguments?

sunshineRunner22 commented 3 weeks ago

Hi, I tried renaming the OPC UA arguments to the idShort, unfortunatley same issues occurs. Please see the model.json (can't upload aasx-file here) and config.json. I also attach the Python code, which creates the OPC UA Test-Server with the TestOperation-method. Thank you! config.json model.json `from opcua import Server, ua import time

server = Server() url = "opc.tcp://localhost:48010" server.set_endpoint(url) name = "OPCUA_TEST_SERVER" addspace = server.register_namespace(name)

node = server.get_objects_node()

def TestOperation(parent, input): return [ua.Variant(input.Value, ua.VariantType.String)]

input_argument = ua.Argument() input_argument.Name = "Input" input_argument.DataType = ua.NodeId(ua.ObjectIds.String) input_argument.ValueRank = -1 input_argument.ArrayDimensions = [] input_argument.Description = ua.LocalizedText("Input-String")

output_argument = ua.Argument() output_argument.Name = "Output" output_argument.DataType = ua.NodeId(ua.ObjectIds.String) output_argument.ValueRank = -1 output_argument.ArrayDimensions = [] output_argument.Description = ua.LocalizedText("Output-String")

operation_node = node.add_method(addspace, "TestOperation", TestOperation, [input_argument], [output_argument])

server.start()

print(f"Server started {url}")`

fvolz commented 3 weeks ago

Hi, we discovered an issue in the eclipse/milo Client method: readInputArgumentsAsync() which occurs when using Python OPC UA SDK. We will create an issue in the milo repo. In the meantime, you could try setting up the server with eclipse/milo Server SDK. If you are interested, we can provide you our Java Server Test JAR. Let me know via mail: friedrich.volz@iosb.fraunhofer.de

fvolz commented 3 weeks ago

https://github.com/eclipse/milo/issues/1329

sunshineRunner22 commented 2 weeks ago

Thanks for the infos! I was already able to run some tests with the Eclise Milo public demo UA server.

Since I'm not too familiar with Java development, is there an easy way to try out the fix mentioned in eclipse/milo#1329?

mjacoby commented 2 weeks ago

I guess that depends on what you consider easy. Also, as highlighted by the developer of milo, this fix is only available on a development branch right now, meaning that it might be not working as expected. Without actually testing it, I would assume the following should do the trick to get the fix working (assuming the dev/1.0 branch of milo is working and backwards compatible to version 0.6.14 which FA³ST Service is currently using, which is not guaranteed as per semantic versioning convention there might be breaking changes while the major version is still at 0, even if the version number only changes the minor version).

The final output file to use can be found at ./starter/target/starter-1.2.0-SNAPSHOT.jar

However, I would not recommend doing that. The reason for the exception is, that you are working with an OPC UA server that is not correctly implemented and should be fixed. The correct way would be for the maintainers of your OPC UA server library to fix the underlying issue in their code as described at https://github.com/FreeOpcUa/opcua-asyncio/issues/1529. If the maintainers are not willing or able to do so I recommend either using a different server library or forking and fixing it yourself.

sunshineRunner22 commented 2 weeks ago

Alright, thanks, I'll continue with a different OPC UA server then.