Skip to content

OPC UA method call via Api is slow #2421

@Haeavar

Description

@Haeavar

Describe the bug
We are using the OPC UA file mechanism to create files on the device. For that, we call a OPC UA method via the Api /v2/call with following body:

  {
    "connection": {
      "endpoint": {
        "url": "opc.tcp://host.opcsrv.internal:4842",
        "securityMode": "None"
      }
    },
    "request": {
      "header": {
        "operationTimeout": 180000
      },
      "objectId": "nsu=http://..../;s=FileTransferTest",
      "methodId": "nsu=http://..../;i=7005",
      "arguments": [
        {
          "value": "60",
          "dataType": "UInt32"
        },      
        {
          "value": "<around 500KB base64 encoded bytes>",
          "dataType": "ByteString"
        }
      ]
    }
  }

Each call needs more than 2 seconds to be finished. The most of the time is needed to validate the bound parameter 'request' of type 'Azure.IIoT.OpcUa.Publisher.Models.RequestEnvelope`1[Azure.IIoT.OpcUa.Publisher.Models.MethodCallRequestModel]'

See following log output:

2025-09-09T18:38:23.344087700Z [25-09-09 18:38:23.3433] dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[26]
2025-09-09T18:38:23.344378600Z       => SpanId:a98fb073fca824f6, TraceId:43c8dfd79e939c62a20b2fa9514c0af2, ParentId:19542bdb3ad6de38 => ConnectionId:0HNFFPT5UFG1K => RequestPath:/v2/call RequestId:0HNFFPT5UFG1K:00000002 => Azure.IIoT.OpcUa.Publisher.Module.Controllers.GeneralController.MethodCallAsync (Azure.IIoT.OpcUa.Publisher.Module)
2025-09-09T18:38:23.344502700Z       Attempting to validate the bound parameter 'request' of type 'Azure.IIoT.OpcUa.Publisher.Models.RequestEnvelope`1[Azure.IIoT.OpcUa.Publisher.Models.MethodCallRequestModel]' ...
2025-09-09T18:38:25.536188000Z [25-09-09 18:38:25.5359] dbug: Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder[27]
2025-09-09T18:38:25.536225000Z       => SpanId:a98fb073fca824f6, TraceId:43c8dfd79e939c62a20b2fa9514c0af2, ParentId:19542bdb3ad6de38 => ConnectionId:0HNFFPT5UFG1K => RequestPath:/v2/call RequestId:0HNFFPT5UFG1K:00000002 => Azure.IIoT.OpcUa.Publisher.Module.Controllers.GeneralController.MethodCallAsync (Azure.IIoT.OpcUa.Publisher.Module)
2025-09-09T18:38:25.536229700Z       Done attempting to validate the bound parameter 'request' of type 'Azure.IIoT.OpcUa.Publisher.Models.RequestEnvelope`1[Azure.IIoT.OpcUa.Publisher.Models.MethodCallRequestModel]'.

Expected behavior
The call should be fast without any overhead. For us, it would be okay to skip the validation of the RequestEnvelope<MethodCallRequestModel>) but you might find a better solution.

Workaround
If we add following code snippet in the Startup, the validation is skipped and the request is fast.

services.AddMvc(options => { options.ModelMetadataDetailsProviders.Add( new SuppressChildValidationMetadataProvider(typeof(RequestEnvelope<MethodCallRequestModel>))); });

Additional context
Version: 2.9.15-rc.11

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions