"NetCode RPC has not been consumed" after package upgrade

Hello everyone,

After upgrading Entities, Netcode for Entities, etc. from 1.0.16 to 1.2.3, we have problems regarding the sending and receiving of RPC commands.

In the specific case, we send an RPC for each entitiy with a NetworkId (i. e. for each connection entity) that doesn’t have a custom tag component (as a first message), and add this component afterwards. The SendRpcCommandRequest is created with the entity that has the NetworkId as TargetConnection.

This did work before, but it doesn’t work reliably anymore. When it doesn’t work, we get the following error message:

[ServerWorld] NetCode RPC Entity(359:3) has not been consumed or destroyed for '4' (MaxRpcAgeFrames) frames! Assumed unhandled. Either a) call .Consume(), or b) remove the ReceiveRpcCommandRequestComponent component, or c) destroy the entity.

The curious part here is: the ReceiveRpcCommandRequest entity is not created in the client world, but in the server world. I tested already to

  • resend the Rpc on the same network connection if it arrives on the server
  • send the Rpc again after a few seconds if no message from the client was received

however the Rpc always ends up on the server side if the game is in this erroneous state.

Why this is unreliable: for me, roughly every first time it misbehaves and subsequent times (without Unity restart and without recompilation) it works. For a colleague of mine it doesn’t work at all. Further, if I use Debug.Break() after creating the Rpc entity and then step through frame by frame, it seems to generally work.

We’re attempting the upgrade to integrate Steam Networking, which seemingly isn’t possible or viable in lower versions of the packages, e. g. because there is no network type “Custom” besides IPv4 and IPv6.

What could we do to narrow down the issue?

Best regards,
Richard

First question: is the system that create the RPC running only on the server or (just because of a mistake) also run on the client ? Because that is the only reason I can see that RPC entity (with a ReceiveRpcCommandRequest) is being added to the server.

Second: just to be sure: aren’t you creating a local (on the server) entity with the ReceiveRpcCommandRequest instead of the SendRpcCommandRequest ?

The server never create an RPC with a SendRpcCommandRequest in its own world, unless you are:

  • Creating it yourself
  • Enqueueing a RPC manually inside the IncomingRpcDataStreamBuffer (that is not probably the case)
  • There is a tremendous bug we never encountered so far.

The other possibility is that you connection setup is such that the packet you sent out for that connection is actually being received by the server socket.
That seem very unlikely the case.

In order to understand what it is going on:

  • First double check your systems and entity creation.
  • You can check what the RpcSystem (on the server) is doing when it send out that RPC.
  • Put a breakpoint on the NetworkStreamReceiveSystem, more specifically where the connections events are handled, and check that what and if RPCs are received (and in which world).