Getting crashes because of the RPC size

Hello everyone,

I’m trying to achieve as many users as possible with the NetCode for Entities package to see if I can develop an MMO with it. I have a raw project with basic things such as click to move, cast one skill, login, and register linked to MongoDB. The problem is that I’m using the RPC system to broadcast a message saying an entity needs to play an animation.

The RPC message is right here;

public struct RPC_Gameplay_Monto_Animation_Play : IRpcCommand
{
    public Entity Target;

    public int Key;
    public bool Value;
}

When I put ~150 thin clients, the server crashes with this error message;

“An RPC was too big to be sent, reduce the size of your RPCs”

Besides this RPC message, I have 3 more RPCs, but they are being used 3 times only for each client. It’s login request and response, the other one is to say the client loaded the game and ready to being set as ingame. So, I don’t think it’s related to other RPCs. It seems like it’s related to the animation RPC. Every 5 seconds, all the thin clients cast a skill that triggers the animation RPCs to be sent. So, every 5 seconds, 150 RPCs are sent to all players.

Hey Dturk, we’ve hardened RPCs with more size validation in the upcoming 1.3.x release, but it sounds like you’re encountering a recently found (by said validation) issue where the ProtocolVersion internal RPC has a size that is off by one, which IIRC can manifest like the error you see above. Fix by removing the minus one subtraction in lenWriter.WriteUShort((ushort)(writer.Length - msgHeaderLen - 1)); inside RpcCollection.SendProtocolVersion (aprox line 251).

Alternatively, delaying sending of RPCs by one frame should also fix this.

Please LMK if either of these fixes do not work.

2 Likes

Hello NikiWalker,

Thank you for your answer. It seems like it’s fixed the problem. I just removed the subtraction from the code. TBH, I have to tell you this: It’s pretty impressive that 175 thin clients are spamming skills each 500ms and moving with pathfinding, and it only costs ~%0, rarely spikes to ~%1 CPU usage on i7-12700KF. Awesome. I can’t try adding more because 32 GB is not enough to handle more thin clients on the editor, but it’s good for now.

2 Likes

Great news, and very much appreciate you saying so! Gotta admit: One of the best things about working on Netcode for Entities is seeing the insane performance achievable in DOTS - my colleagues are wizards, frankly. We always have room to improve - thin client CPU and memory overhead is relatively high on our backlog.

3 Likes