dotnet / dotnet/MQTTnet

How to know when the ManagedMqttClient is subscribed?

Open
#1,265 12 comments 5 reactions 0 assignees View on GitHub
question
Dominant language
C#
Stars
5.1k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

### Describe your question
We have a use case where I need to know when the `ManagedMqttClient` is subscribed to a topic after calling `SubscribeAsync`. I have several workarounds for the problem, such as calling `SubscribeAsync` on the `InternalClient` or waiting for a short period before continuing. But I was wondering if there is a proper way for knowing when the `ManagedMqttClient` has subscribed to the topic?

We need to know when we are subscribed before starting other tasks. Otherwise we end up missing messages because the `ManagedMqttClient` implements the operation asynchronously. It can easily be reproduced if you call `PublishAsync` directly after `SubscribeAsync` on the same topic - the message will likely be published before you are subscribed.

### Which project is your question related to?
- ManagedClient

Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.