dotnet / MQTTnet

MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.
MIT License
4.5k stars 1.07k forks source link

MQTTClient Thread-safety: Publishing #2077

Closed fazho closed 2 months ago

fazho commented 2 months ago

Describe your question

I am using MqttClient class (https://github.com/dotnet/MQTTnet/blob/2fdbb02dc8922937e751a75a1f2f3163dcf45300/Source/MQTTnet/MqttClient.cs#L21) to publish MQTT messages. The method I am calling is PublishAsync(). Right now my code can access the same MqttClient object from multiple threads. Is MqttClient or PublishAsync() thread safe?

Which project is your question related to?

fazho commented 2 months ago

@chkr1011 for visibility. Thanks!

fazho commented 2 months ago

QoS Level: at least once

chkr1011 commented 2 months ago

The client is not thread safe.

fazho commented 2 months ago

Deep-dive thread: https://github.com/dotnet/MQTTnet/issues/2078