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