unity network_error ai_generated true

InvalidOperationException: Cannot enqueue unreliable message. The unreliable message queue is full.

ID: unity/network-unreliable-message-queue-full

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
1Evidence
2024-02-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Unity 2022.3.15f1 active
Unity 2023.2.0b5 active
Netcode for GameObjects 1.6.0 active

Root Cause

The network transport layer's unreliable message queue has reached its capacity, typically due to sending too many unreliable messages without processing or a network buffer leak.

generic

中文

网络传输层的不可靠消息队列已达到容量上限,通常是由于发送了过多不可靠消息而未处理,或网络缓冲区泄漏。

Official Documentation

https://docs.unity3d.com/Packages/[email protected]/manual/index.html

Workarounds

  1. 80% success Reduce the frequency of unreliable messages by implementing a send rate limiter. For example, in a script, use a timer to send at most 10 messages per second: `if (Time.time - lastSendTime > 0.1f) { SendUnreliableMessage(); lastSendTime = Time.time; }`.
    Reduce the frequency of unreliable messages by implementing a send rate limiter. For example, in a script, use a timer to send at most 10 messages per second: `if (Time.time - lastSendTime > 0.1f) { SendUnreliableMessage(); lastSendTime = Time.time; }`.
  2. 70% success Increase the unreliable message queue size in the network transport configuration (e.g., in Unity Transport, set `maxUnreliableQueueSize` to a higher value like 1024).
    Increase the unreliable message queue size in the network transport configuration (e.g., in Unity Transport, set `maxUnreliableQueueSize` to a higher value like 1024).
  3. 85% success Monitor and log outgoing message counts to identify and fix scripts that are accidentally sending messages in Update() without checks.
    Monitor and log outgoing message counts to identify and fix scripts that are accidentally sending messages in Update() without checks.

中文步骤

  1. 通过实现发送速率限制器来降低不可靠消息的频率。例如,在脚本中使用计时器,每秒最多发送 10 条消息:`if (Time.time - lastSendTime > 0.1f) { SendUnreliableMessage(); lastSendTime = Time.time; }`。
  2. 在网络传输配置中增加不可靠消息队列大小(例如在 Unity Transport 中,将 `maxUnreliableQueueSize` 设置为更高的值,如 1024)。
  3. 监控并记录传出消息数量,以识别并修复在 Update() 中无意发送消息的脚本。

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Increasing the queue size without addressing the root cause (e.g., message spam) may only delay the error and cause memory issues.

  2. 90% fail

    Restarting the game client clears the queue temporarily but does not fix the underlying excessive message generation.