Azure / Industrial-IoT

Azure Industrial IoT Platform
MIT License
519 stars 211 forks source link

Unable to add application per discovery #2275

Closed kappa-lhirsch closed 4 hours ago

kappa-lhirsch commented 2 days ago

Describe the bug I use the Industrial Web Api and the publisher module to communicate with my OPC-Server.

Both running Version 2.9.9

When I try to add a application via the API POST https://{{OPC-SERVICEURL}}/registry/v2/applications with the discoveryUrl parameter. the publisher module is showing the following logs:

[24-07-01 08:34:43.1406] info: Azure.IIoT.OpcUa.Publisher.Discovery.ProgressPublisher[0]
      (null): Discovery operation started.
[24-07-01 08:34:43.2211] info: Azure.IIoT.OpcUa.Publisher.Discovery.ProgressPublisher[0]
      (null): Searching 1 discovery urls for endpoints...
[24-07-01 08:34:43.2352] info: Azure.IIoT.OpcUa.Publisher.Discovery.ProgressPublisher[0]
      (null): Trying to find endpoints on opc.tcp://192.168.11.12:4840/...
[24-07-01 08:34:44.8880] info: Azure.IIoT.OpcUa.Publisher.Discovery.ProgressPublisher[0]
      (null): Found 1 endpoints on opc.tcp://192.168.11.12:4840/.
[24-07-01 08:34:44.8948] info: Azure.IIoT.OpcUa.Publisher.Discovery.ProgressPublisher[0]
      (null): Found total of 1 servers ...
[24-07-01 08:34:44.9115] info: Azure.IIoT.OpcUa.Publisher.Discovery.NetworkDiscovery[0]
      Uploading 1 results...
[24-07-01 08:34:45.0740] info: Azure.IIoT.OpcUa.Publisher.Discovery.NetworkDiscovery[0]
      1 results uploaded.
[24-07-01 08:34:45.0756] info: Azure.IIoT.OpcUa.Publisher.Discovery.ProgressPublisher[0]
      (null): Discovery operation completed.

Although this output seems normal to me, the application does not show up when getting the applications in the registry.

To Reproduce Steps to reproduce the behavior:

  1. Install IIoT publisher module version 2.9.9
  2. Install IIoT web api version 2.9.9
  3. See above

Expected behavior The application shows up in the registry

marcschier commented 2 days ago

I called the POST API using the service CLI tool (apps add -u <url>) and it worked just fine. Have you looked at the server log to see if there are any errors reported?

kappa-lhirsch commented 2 days ago

Is there any documentation about the usage of the cli?

marcschier commented 2 days ago

The cli which we also publish as a container image (mcr.microsoft.com/iot/industrial-cli:latest) has a help, you can start it in console mode by passing the "console" keyword as first argument. The code is in https://github.com/Azure/Industrial-IoT/blob/main/src/Azure.IIoT.OpcUa.Publisher.Service.Sdk/cli/Program.cs. In essence it is just a CLI on top of the REST api, but not meant for production use, rather for testing/exercising the API.

kappa-lhirsch commented 1 day ago

I noticed some interesting behavior with the API. First of all I'm still not able to discover servers via the API. However when i make a PUT call to the endpoints endpoint https://{{OPC-SERVICEURL}}/registry/v2/endpoints with the same discoveryUrl parameter, the endpoint and also the application it belongs to is discovered.

My second question is, how can i connect to an endpoint, because their is no connect route available anymore in version 2.9.9?

marcschier commented 23 hours ago

Quick comment: Connect happens now automatically when you send your first request. No need to activate/deactivate in 2.9.

marcschier commented 4 hours ago

Yes there are essentially 3 API calls that support discovery:

  1. Register Server
  2. Discover Servers
  3. Register single endpoint and associated server

(application == server)

You can use the endpoint id (e.g. from List endpoints) in the opc ua service calls.