瀏覽代碼

fixed high load on server

release/3.x.x
JanEggers 7 年之前
父節點
當前提交
12a275918e
共有 1 個檔案被更改,包括 6 行新增0 行删除
  1. +6
    -0
      MQTTnet.Core/Server/MqttClientMessageQueue.cs

+ 6
- 0
MQTTnet.Core/Server/MqttClientMessageQueue.cs 查看文件

@@ -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…
取消
儲存