can't send RPC function since no connection was started

I am retrofitting my code with RPC calls and Unity isn’t allowing me to call them when I’m not connected which is a problem as I am testing everything non connected. What’s the work around ?

I’m bumping this one before I start coding around this bug/limitation …
(aren’t RPC folding back to sendmessage behavior when no network connection exist?)

Your can fire of RPCs when running as a server, which you can do when testing. If you are not connected to anything there is nothing to do with the RPC, hence the error. This is by design, it a Remote Procedure Call after all.

I’m going to Necro this thread since I found it while googling solutions for a simular problem.

A simple hack I quickly came up with was to simply create a server inside the script’s awake function if we’re neither client or server currently.

This allows for simple non-networked scene testing of some functionality:

private void Awake ()
{
    // Create a fake server if we are neither client nor server so the RPC calls will function
    if (!(Network.isServer || Network.isClient))
    {
	Network.InitializeServer(1, 25000, false);
    }
}

that’s a really handy tip for checking if you have a connection! thx

That is indeed a great tip. Certainly during development.

You’re ultimately probably better to wait until the connection, with something like OnPlayerConnected,

but again this is a great tip especially during development. Avoids the crash in the first few seconds while everything gets connected!

This question asked a decade ago was for the previous networking API, not Unet.

Quite true Joe ! But this trick still works when you’re using RPC functions in 2018 !