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

Setting Heartbeat Interval with API is using milliseconds instead of seconds #2292

Closed
kappa-lhirsch opened this issue Jul 15, 2024 · 8 comments
Labels
bug Something isn't working
Milestone

Comments

@kappa-lhirsch
Copy link

kappa-lhirsch commented Jul 15, 2024

Hello,
I'm using the publisher module und web api with version 2.9.2.
When I'm publishing a node I set the PublishingInterval, SamplingInterval andHeartbeatInterval to a string of the format:
[d.]hh:mm:ss[.ffffff] like written in the documentation.

The backend converts this timespan string to milliseconds, eg. '00:01:00' to '60000' milliseconds.
However since the HeartbeatInterval is configured in seconds, I'm not sure why this is different but hey, the resulting Interval is 60000 seconds aka '16h and 40minutes'.
So the HeartbeatInterval is off by a factor of 1000!!

Also when reading the published nodes, the api returns 00:01:00 although it's 60000 seconds, you can look it up in the config file. After restarting the module and reading the published nodes again, the api returns the "correct" 16:40:00.

To Reproduce
Steps to reproduce the behavior:

  1. Install publisher V2.9.2
  2. Publish a node with a heartbeat interval

Expected behavior
HeartbeatInterval is interpreted properly.

@marcschier marcschier added the bug Something isn't working label Jul 15, 2024
@marcschier marcschier added this to the 2.9.10 milestone Jul 15, 2024
@kappa-lhirsch
Copy link
Author

Will this be fixed?

@marcschier
Copy link
Collaborator

I need to first repro. You can help me if you can confirm this is an issue on 2.9.9 (last release). But this is something I would do hopefully this week.

@marcschier
Copy link
Collaborator

I re-read what you are doing, you set the HeartbeatInterval to a string? It is a number value, which is the number of seconds.
There is a HeartbeatIntervalTimespan property that you must use if you want to specify a duration string. Can you confirm/post the request you are sending and the endpoint you are sending to? If this is a doc issue, can you point me to it?

@kappa-lhirsch
Copy link
Author

kappa-lhirsch commented Jul 23, 2024

image
The swagger docs, and also the docs on github, define the 'HeartbeatInterval' as string($date-span)

The request I make is the following:
POST https://{{OPC-SERVICEURL}}/publisher/v2/publish/{{endpointId}}/start
Payload:

{
    "item": {
        "nodeId": "{{nodeId}}",
        "publishingInterval": "00:01:00",
        "samplingInterval": "00:01:00",
        "heartbeatInterval": "00:01:00"
    },
    "header": {
        "elevation": {
            "type": "UserName",
            "value": {
                "user": "{{user}}",
                "password": "{{password}}"
            }
        },
        "namespaceFormat": "Uri"
    }
}

You can see the HeartbeatInterval is the same as the Publishing- and SamplingInterval.
After this request the config file shows the following:

{
        "Id": "{{nodeId}}",
        "OpcPublishingInterval": 60000,
        "HeartbeatInterval": 60000,
        "OpcSamplingInterval": 60000
}

The HeartbeatInterval is set to '60000' which is not correct since it should be 60.

@kappa-lhirsch
Copy link
Author

I tested it with V2.9.9 and the problem still exists.

@marcschier
Copy link
Collaborator

Thank you so much, now I understand better, you are using the start/stop API. Thanks for the details! And thanks for re-testing.

@kappa-lhirsch
Copy link
Author

I think a found the problem.
TotalMilliseconds is used instead of TotalSeconds:
https://github.com/Azure/Industrial-IoT/blob/2.9.9/src/Azure.IIoT.OpcUa.Publisher/src/Storage/PublishedNodesConverter.cs#L218

@marcschier
Copy link
Collaborator

Great find, yes, I also just fixed this in the open pull request and added unit tests for this API.

marcschier added a commit that referenced this issue Jul 27, 2024
…2297)

* Update nuget dependencies
* Publish Start/stop tests
* Fix seconds heartbeat bug #2292 
* Fix condition handling stop working and heartbeat timer stopping on reconnect #2288 
* Add ipi option #2299 
* Session per writer #2298 
* Setting ska and slt options to default to 0 #2294 
* Add auto calculation of qs. #2300 
* Document browse path formats and fix issue when node id is missing #2296 
* API and sample to dump session, channel and subscription diagnostics from server #2303
* Better validation for missing node id on inputs to the configuration API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants