ApplicationMessageReceived isn't Async
See original GitHub issueApplicationMessageReceived isn’t Async which breaks the async flow and requires the event implementation to do .GetAwaiter().GetResult();.
Consider adding the ability to register a Func<Task> to flow the async context and also the cancellation token.
var mqttOptions = new MqttClientOptionsBuilder()
//...
.WithApplicationMessageReceiver(MyReceiver) // WithApplicationMessageReceiver(Func<MqttApplicationMessage, CancellationToken, Task>)
//...
.Build();
Task MyReceiver(MqttApplicationMessage message, CancellationToken cancellationToken)
{
// Do async stuff
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
c# - How to receive published message when mqtt async ...
In Publish button, i have written code to publish the message and in mosquitto cmd prompt, i can receive the message. In viceversa,...
Read more >Publish from MessageReceivedHandler doesn't work #648
When I Publish message from handler client.UseApplicationMessageReceivedHandler(async e => { await client.PublishAsync(message); }); I am ...
Read more >Understanding Control Flow with Async and Await in C# | ...
This refers to the situation where you do not want to await an asynchronous method and you're not particularly concerned about when it...
Read more >Asynchronous message-based communication
Since it's a message-based communication, the client assumes that the reply won't be received immediately, and that there might be no response ...
Read more >Sending Asynchronous Messages
Send an asynchronous request using the tpacall() function. Get an asynchronous reply using the tpgetrply() function. The type of asynchronous processing ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

On the develop branch the
ApplicationMessageReceivedevent is deprecated and there is an alternative and MQTTnet does now call theReceivedApplicationMessageHandlerand awaits that handler. That makes the api async, but the internals of MQTTnet are not async yet. This issue overlaps with the discussion we had in the PR #550. I now created #556 to discuss and track those changes.hi @chkr1011 I think is feature is implemented and should close this issue