Skip to content

[PubSub] MQTT Keep Alive calculation does not consider WriterGroups #3227

@jnsjll

Description

@jnsjll

Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

According to the specification, an MQTT Keep Alive value should be set that is slightly higher than the highest KeepAliveTime setting of all writer groups. Currently, 5 seconds are used for MQTT Keep Alive.

This is because when the value is calculated first in the MqttPubSubConnection class, there are no writer groups present. After adding writer groups, this value is not updated.

Expected Behavior

MQTT Keep Alive is set correctly.

Steps To Reproduce

Compile and run the ConsoleReferencePublisher application.
Add a breakpoint here


and observe the value of m_publisherMqttClientOptions.KeepAlivePeriod.

Environment

- OS: Windows 11
- Runtime: .NET 8
- Nuget Version: 1.05.374
- Component: Opc.Ua.PubSub

Anything else?

A possible fix is provided here: 54e3e6e#diff-427c299ba5e9c1108f63c202a6f937c366e47427e065505935aa21a17a890c6a
It does not consider manually changing this value via the PublisherMqttClientOptions property, though.

Another remark regarding the ConsoleReferencePublisher application:
currently both Writer Group PublishingInterval and KeepAliveTime are set to 5000. PublishingInterval is in ms, KeepAliveTime in seconds, however.
I suggest

PublishingInterval = 5000, // milliseconds
KeepAliveTime = 5, // seconds

Metadata

Metadata

Assignees

Labels

enhancementAPI or feature enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions