Possible bug: client cannot receive RPC from server in v1.2.0

Hey all, I recently updated an old project to Unity Netcode for GameObjects v1.2.0 from v1.1.0 and noticed that whenever the client connects to the server the clients console logs this error message: ‘Trying to receive ClientRpcMessage from client 0 which is not in a connected state.’

After some digging I have found that on all versions although NetworkManager.Singleton.IsApproved, NetworkManager.Singleton.IsServer, and NetworkManager.Singleton.IsClient are all true for the host after they start the server and are approved for connection the field NetworkManager.Singleton.IsConnectedClient is always false…

In the version v1.2.0 this seems to be causing the ‘Trying to receive ClientRpcMessage from client 0 which is not in a connected state.’ error message when clients connect.Not only do I receive this error message the client does not receive RPC messages from the server (although the server receives them from the client).

In v1.1.0 or older this seems to be no problem, even though ‘isConnectedClient’ is still false the client is able to reliably receive RPC messages from the server.

Any insight into this would be appreciated. Does this sound like a bug I need to report or did something change in v1.2.0 that requires me to refactor my code? Thanks in advance for any ideas.

EDIT: After viewing the source code I see the ‘IsConnectedClient’ field is set after scene synchronization or immediately after the approval callback if scene management is disabled. In my case I’ve disabled scene management but I’ve tested in both cases and neither work.

1 Like

I experienced this as well. In my case I was trying to call a ClientRpc method in a coroutine I had started in OnNetworkSpawn (and, while flailing for an answer, in an async void method I converted that coroutine into).

I was using a coroutine because I wanted to re-check for the existence of an object, and only proceed with some logic if it was present, so I had a while loop containing the check, then a yield return new WaitForSeconds if it wasn’t there yet.

What fixed it for me was changing that whole OnNetworkSpawn->Coroutine faff to just using Update, and checking for the existence of the object in there. Basically replacing my while loop with the Update loop. Suddenly the mysterious warning went away and the client received the RPC I sent.

So I’m not sure if there’s some issue sending certain messages from coroutines, or from coroutines started in OnNetworkSpawn, but using Update was my fix.

1 Like

It is definitely is a bug of some kind, I’ve solved this by downgrading to v1.1.0 for the short term. No time to file a bug report unfortunately.

v1.1.0 works for my use cases so all is well. Hopefully someone with more time (or motivation) than me files a proper bug report so this can get solved sometimes in the next few years. :stuck_out_tongue:

Knowing Unity and the Unity forums however I’m sure a moderator will close this thread for some reason like ‘not relevant’, several people will report the bug, and then years will go by without a fix haha.

It seems lots of Rpc related changes and improvements were made in v1.2.0 so I’m not surprised some bugs cropped up. It still could be that the use-case has changed completely and they just haven’t properly documented the changes, who knows. Thankfully downgrading is a perfectly fine fix.

Either way thank you for sharing your experience with this bug as well.

Hi @Crazycarpet , a few things:

  1. Did you try updating to 1.4.0?
  2. According to the doc, it could be that your OnNetworkSpawned is called too early (there are differences between in-scene objects and dynamic ones). What are you trying to do in that RPC?