ManagedMqttClient Issue with sending message just after Start.
- Dominant language
- C#
- Stars
- 5.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
### Describe the bug
I have the following case:
One server, one client (producer), another client (consumer).
I start the server.
I start the producer and I send immediately a message with retain flag.
I start the consumer and subscribe to the topic.
I am facing a strange behavior where sometimes, the retained message is not received by the consumer.
I am able to work around if I add a Task.Delay(1) between the start of producer and the enqueue of the message.
### Which component is your bug related to?
- ManagedClient v4.3.1.873
### To Reproduce
Open the attached visual studio solution, execute the unit tests.
There is 2 tests, one where the server is restarted at each loop, another where the server is started only once.
I have Theory, (one with Task.Delay(0) failing, one with Task.Delay(1) success)
### Expected behavior
A reproducible behavior without Task.Delay or a way to be sure that initialization is ok.
### Code example
See attached solution.
[MqttNetTester.zip](https://github.com/dotnet/MQTTnet/files/12729906/MqttNetTester.zip)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.