Handling Unity Transport errors

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):

private unsafe void SendBatchedMessage(ulong clientId, ref NativeArray<byte> data, NetworkPipeline pipeline)
{
            var payloadSize = data.Length + 1; 
            var result = m_Driver.BeginSend(pipeline, ParseClientId(clientId), out var writer, payloadSize);
            if (result == 0)
            {
               (...)
            }

            Debug.LogError($"Error sending the message:{ErrorUtilities.ErrorToString((Networking.Transport.Error.StatusCode)result, clientId)}");
}

private unsafe void SendMessageInstantly(ulong clientId, ArraySegment<byte> data, NetworkPipeline pipeline)
{
            var payloadSize = data.Count + 1 + 4;
            var result = m_Driver.BeginSend(pipeline, ParseClientId(clientId), out var writer, payloadSize);

            if (result == 0)
            {
                (....)
            }

            Debug.LogError($"Error sending the message: {ErrorUtilities.ErrorToString((Networking.Transport.Error.StatusCode)result, clientId)}");
}

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’?

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.

Thank you for the quick response. I’m glad to hear that the problem is acknowledged.

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)

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.

Add my project to now being impacted by this too :frowning:

is a fix pack build available on github ?

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).