Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

If the packet size is more than 60k, a NetworkSendQueFull error occurs when sending.

Discussion in 'Unity Transport' started by ulralra_unity, Feb 4, 2022.

  1. ulralra_unity

    ulralra_unity

    Joined:
    Apr 9, 2021
    Posts:
    9
    Even if you increase UnityTransport's Queue Size and Batch Size, if the size of the packet you send at once exceeds 60k, you will get an error in the Write function of ReliableUtility class.
    Looking at the code, FragmentationPipelineStage cuts packets into NetworkParameterConstants.MTU units, the error seems to happen because the window size is 32.
    (32 * MTU ~= 42k)

    If there are about 1,000 NetworkObjects in a scene, this happens because you receive 1,000 pieces of information at once when you access.
    In this case, can we double the MTU?
    Or is there another way?
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    102
    There was indeed a limitation on the maximum message size, but we lifted that limit in version 1.0.0-pre.5 of the adapter package (
    com.unity.netcode.adapter.utp
    ). The limit can be set arbitrarily high now (although I'd still advise not setting it higher than what your game requires). The limit can be controlled with the 'Max Payload Size' setting, which replaces the 'Send Queue Batch Size' one.
     
  3. ulralra_unity

    ulralra_unity

    Joined:
    Apr 9, 2021
    Posts:
    9
    Thank you very much!!

    1.0.0-pre5 was received and applied. When I connected to a server with 1000 objects by setting MaxPayloadSize to 100000, the following error occurred.

    [Netcode] Incoming Data From 4294967296: 72698 bytes

    OverflowException: Not enough space in the buffer to read recorded synchronization data size.
    Unity.Netcode.SceneEventData.CopySceneSynchronizationData (Unity.Netcode.FastBufferReader reader) (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/SceneManagement/SceneEventData.cs:512)
    Unity.Netcode.SceneEventData.Deserialize (Unity.Netcode.FastBufferReader reader) (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/SceneManagement/SceneEventData.cs:458)
    Unity.Netcode.NetworkSceneManager.HandleSceneEvent (System.UInt64 clientId, Unity.Netcode.FastBufferReader reader) (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/SceneManagement/NetworkSceneManager.cs:1797)
    Unity.Netcode.SceneEventMessage.Receive (Unity.Netcode.FastBufferReader reader, Unity.Netcode.NetworkContext& context) (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Messaging/Messages/SceneEventMessage.cs:16)
    Unity.Netcode.MessagingSystem.HandleMessage (Unity.Netcode.MessageHeader& header, Unity.Netcode.FastBufferReader reader, System.UInt64 senderId, System.Single timestamp, System.Int32 serializedHeaderSize) (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Messaging/MessagingSystem.cs:263)
    UnityEngine.Debug:LogException(Exception)
    Unity.Netcode.MessagingSystem:HandleMessage(MessageHeader&, FastBufferReader, UInt64, Single, Int32) (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Messaging/MessagingSystem.cs:267)
    Unity.Netcode.MessagingSystem:processIncomingMessageQueue() (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Messaging/MessagingSystem.cs:282)
    Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate() (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Core/NetworkManager.cs:1225)
    Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage) (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Core/NetworkManager.cs:1196)
    Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage) (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Core/NetworkUpdateLoop.cs:149)
    Unity.Netcode.<>c:<CreateLoopSystem>b__0_0() (at Packages/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Core/NetworkUpdateLoop.cs:172)
     
  4. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    102
    Interesting! You might have more luck posting on the Netcode for GameObject subforum, since this is where the error originates from.

    Although I guess if the transport was feeding partial messages or garbage to Netcode, the error would be similar. If you have a project you can share publicly where this is reproducible, I'd be curious to have a look. Especially since we did test spawning 1000 objects when writing the fix for pre.5 and it did seem to work then.
     
  5. ulralra_unity

    ulralra_unity

    Joined:
    Apr 9, 2021
    Posts:
    9
    Thank you for your quick reply!

    https://dev-puppyred.s3.amazonaws.com/test/com.unity.multiplayer.samples.coop-1.0.1-pre.zip
    (uploading file size limit....)

    It is a project with a very slight revision of the bossroom sample project.
    - BossRoom.unity : NetworkObject has been increased by about 1,000.
    - NetworkManager.UTP : MaxPayloadSize to 100000

    Reproducing step.
    - Build server after turn on Server Build option in the building settings.
    - Run the built server (automatically listening on 0.0.0.0 / 9998 port)
    - Play Startup scene in the unity editor, and join to [127.0.0.1 / 9998].

    Thank you!
     
  6. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    102
    Thanks for the reproduction project and steps.

    I had a quick look. The transport doesn't mangle any messages, so that's a good thing. The issue is most probably on the Netcode side. I think it might be hitting this issue (which has a PR opened to fix it).
     
  7. ulralra_unity

    ulralra_unity

    Joined:
    Apr 9, 2021
    Posts:
    9
    Thank you for your reply!
    I'll wait for fixing the bug.
     
unityunity