Browse Source

fixed high load on server

release/3.x.x
JanEggers 7 years ago
parent
commit
12a275918e
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      MQTTnet.Core/Server/MqttClientMessageQueue.cs

+ 6
- 0
MQTTnet.Core/Server/MqttClientMessageQueue.cs View File

@@ -54,6 +54,12 @@ namespace MQTTnet.Core.Server
var consumable = _pendingPublishPackets.GetConsumingEnumerable();
while (!cancellationToken.IsCancellationRequested)
{
if (_pendingPublishPackets.Count == 0)
{
await Task.Delay(TimeSpan.FromMilliseconds(5));
continue;
}

var packets = consumable.Take(_pendingPublishPackets.Count).ToList();
try
{


Loading…
Cancel
Save