diff --git a/Source/MQTTnet/Server/Internal/MqttClient.cs b/Source/MQTTnet/Server/Internal/MqttClient.cs index b0465dda..6d2f59e1 100644 --- a/Source/MQTTnet/Server/Internal/MqttClient.cs +++ b/Source/MQTTnet/Server/Internal/MqttClient.cs @@ -188,6 +188,8 @@ namespace MQTTnet.Server // own exception in the reading loop! while (!cancellationToken.IsCancellationRequested) { + await Task.Yield(); + var packet = await ChannelAdapter.ReceivePacketAsync(cancellationToken).ConfigureAwait(false); if (packet == null) { @@ -315,6 +317,10 @@ namespace MQTTnet.Server { packetBusItem.MarkAsFailed(exception); } + finally + { + await Task.Yield(); + } } } catch (OperationCanceledException)