Search Unity

Question Handling Unity Transport errors

Discussion in 'Multiplayer' started by tiratron11, Dec 1, 2021.

  1. tiratron11

    tiratron11

    Joined:
    Jan 6, 2020
    Posts:
    2
    Hi, everyone!
    I'm going for Netcode custom messages approach for my game with server-client architecture. For sending messages I'm using

    NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(..)

    It's nothing special really.
    So far messages work quite nicely, but often I'm getting these errors, when I'm trying to send large amounts of packets over 'Reliable' pipes.

    Currently unable to queue packet as there is too many inflight packets.
    Unable to allocate packet due to buffer overflow.


    Which it seems, are coming from Unity Transport. I've digged through the code a little bit and found that the errors were coming from the NetworkDriver. But the driver itself is enclosed in UnityTransport class, and there is no way to access it, as it's private. Here are the methods, sending errors (irrelevant code omitted):


    Code (CSharp):
    1.  
    2. private unsafe void SendBatchedMessage(ulong clientId, ref NativeArray<byte> data, NetworkPipeline pipeline)
    3. {
    4.             var payloadSize = data.Length + 1;
    5.             var result = m_Driver.BeginSend(pipeline, ParseClientId(clientId), out var writer, payloadSize);
    6.             if (result == 0)
    7.             {
    8.                (...)
    9.             }
    10.  
    11.             Debug.LogError($"Error sending the message:{ErrorUtilities.ErrorToString((Networking.Transport.Error.StatusCode)result, clientId)}");
    12. }
    13.  
    14. private unsafe void SendMessageInstantly(ulong clientId, ArraySegment<byte> data, NetworkPipeline pipeline)
    15. {
    16.             var payloadSize = data.Count + 1 + 4;
    17.             var result = m_Driver.BeginSend(pipeline, ParseClientId(clientId), out var writer, payloadSize);
    18.  
    19.             if (result == 0)
    20.             {
    21.                 (....)
    22.             }
    23.  
    24.             Debug.LogError($"Error sending the message: {ErrorUtilities.ErrorToString((Networking.Transport.Error.StatusCode)result, clientId)}");
    25. }
    The response code just goes to the logs and nowhere else, the packet is not being sent either.

    The question is: If I can't access the driver\error responses, how am I supposed to account for these errors? I understand, I must be doing something wrong by sending too much data over the time, but how am I supposed to know when it becomes 'too much'?
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    The "buffer overflow" error is most likely caused by a bug in the transport that should be fixed in 1.0.0-pre.4 of com.unity.netcode.adapter.utp. A consequence of that bug would be that reliable pipes would be clogged with unsendable packets which quickly ended up causing "too many inflight packets" errors.

    Now it's also possible to encounter the "too many inflight packets" error on its own when a lot of data is being sent. Right now there's unfortunately not much that can be done to work around that (especially if all the data is caused by NGO-driven synchronization). We understand that this is a problem and are working on a solution.
     
  3. tiratron11

    tiratron11

    Joined:
    Jan 6, 2020
    Posts:
    2
    Thank you for the quick response. I'm glad to hear that the problem is acknowledged.
     
  4. FloHal

    FloHal

    Joined:
    Feb 25, 2013
    Posts:
    38
    Any news about this problem? It's problematic. I have just 2 players and 1 or 2 ServerRPC call per second (max). And i encounter this error on the client side. (host seems to be not affected)
     
  5. RSolids

    RSolids

    Joined:
    May 19, 2021
    Posts:
    22
    Similarly, I was calling 1 RPC on every Update(). 1 host & 1 client.

    After a minute or two (I didn't time it) I go the "Error sending the message: Currently unable to queue packet as there is too many inflight packets." on the client.

    Now, I'm wondering if I should be using some other Update() that I have not found in the docs.
     
  6. jmguillemette

    jmguillemette

    Joined:
    Mar 4, 2015
    Posts:
    53
    Add my project to now being impacted by this too :(


    upload_2022-1-5_18-36-42.png
     
  7. jmguillemette

    jmguillemette

    Joined:
    Mar 4, 2015
    Posts:
    53
    is a fix pack build available on github ?
     
  8. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    The tip of the 1.0.0 release branch contains fixes for both issues ("buffer overflow" and "too many inflight packets" errors). Release 1.0.0-pre.4 should also be officially available quite soon in the package manager.

    For the "too many inflight packets" error, we added a new setting in the inspector called "Max Send Queue Size" that can be tuned to deal with the error (basically, increase it if the error occurs regularly).