-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
enhancementAPI or feature enhancementAPI or feature enhancement
Description
Type of issue
- Bug
- Enhancement
- Compliance
- Question
- Help wanted
Current Behavior
I can observe two different kind of exceptions being logged when stopping a MqttPubSubConnection
. They are caught, however, but preventing them in the first place would avoid giving the impression that there is an error / unexpected exception somewhere.
- When disposing an
UaPubSubApplication
instance that uses anMqttPubSubConnection
or calling itsStop
method, the MQTT client is disconnected. However, its disconnect handler is still in place, trying to reconnect after five seconds, leading to an object disposed exception. This can be seen by enabling logging in the ConsoleReferencePublisher application, pressing CTRL+C and waiting for at least five seconds. - There is a racing condition when calling the
MqttPubSubConnection.Stop()
method at the same time anUaPublisher
is about to publish network messages. That can lead to a situation in which the MQTT client is disconnected already but itsPublishAsync
method is still being called.
Expected Behavior
No exceptions are logged on a graceful stop.
Steps To Reproduce
Enable logging and stop the ConsoleReferencePublisher using CTRL+C and wait for at least five seconds.
A fork demonstrating that behavior is here.
Environment
- OS: Windows 11
- Runtime: .NET 8
- Nuget Version: 1.05.374
- Component: Opc.Ua.PubSub
Anything else?
Could be achieved by
- before disconnecting the MQTT client in the
MqttPubSubConnection
, its disconnect handler is deregistered - setting the
IsRunning
flag to false before disconnecting the MQTT client and checking the flag before publishing network messages
I can provide a PR for that.
Metadata
Metadata
Assignees
Labels
enhancementAPI or feature enhancementAPI or feature enhancement