HELP!?! RPC error on client disconnect?

I don’t understand why this script (run on the server) is giving me an error:

function Update () {
    if (Network.connections.length > 0) {
        myVar = (something else);
        networkView.RPC ("MyFunction", RPCMode.OthersBuffered, myVar);
    }
}

@RPC
function MyFunction (myVar : float) {
}

What I want to happen is for “MyFunction” to be called and the variable “myVar” to be passed over the network while any client is connected. That works, but when the client disconnects I get this error:

Which is what I don’t understand. If the client logs off the network the function should stop running, so why the error? I can’t find anything in the docs that would explain this, how do I fix this??

You should use the disconnect callback to actually kill all your instantiated multiplayer prefabs.

they were bound to network view ids that are obviously no longer valid, but as they are bound they will still be seen as “usable”

I’m not instantiating any multiplayer prefabs. I’m just trying to pass a variable value (float) from the server to the clients.

Maybe not related to your problem. But I wonder why sending RPCMode.OthersBuffered every frame.

how are you managing your player object then?
All just through RPC?

Either case, how does your disconnect handle code look alike on the client and the server? (incl. all the relevant callbacks)

I’m having the same problem and try{}catch{} won’t prevent the error output. Is there any workaround for this?

It is possible that the client disconnects while the RPC is in progress. Especially if you are doing an update every frame.

I’ve had small issues like this before and really, I don’t think there is much you can do about it. Having an error output surely isn’t that bad for this case?

This isn’t causing the application to crash is it?

Having the same issue.

dreamora, yes, I am managing everything through RPCs. Maybe not the best way to do it, but it was the way I knew how to do it. There isn’t much to manage so I guess it isn’t all that bad.

Hogus, I am going to try and see if my program crashes. Hopefully it won’t.

I would guess that the RPC is sent at just before the player disconnects, and that is the reason for the failure. That would make the most sense to me (but I really hope the game doesn’t crash).

The game does not crash on my device, so I guess the problem isn’t terribly important (and I don’t think it is fixable either).

The bug is still here years later… how lame.

I found out that cleaning up the RPCs in the way described here

http://docs.unity3d.com/Documentation/ScriptReference/Network.DestroyPlayerObjects.html

prevents this error from happening.

Cheers,
Ben

Network.RemoveRPCs(player);

doesn’t help

public static void RPCToPlayer(NetworkView targetNetworkView, string name, NetworkPlayer targetPlayer, params object[] arguments)
{
    if (Array.IndexOf(Network.connections, targetPlayer) != -1)
    targetNetworkView.RPC(name, targetPlayer, arguments);
}

also has no effect

server sends an RPC to other players when some player has disconnected, so if 2 players disconnect at the same time i get RPC error even if i clean up the RPCs and check the existing connections

void OnPlayerDisconnected(NetworkPlayer player)
{
    foreach (GameObject gameObject in networkedGameObjectsWithParameters.Keys)
    {
        RemovePlayerVisibleGameObject(player, gameObject, false);
    }

    networkPlayersWithParameters.Remove(player);

    IOwnable[] allIOwnableComponents = FindObjectsOfInterface<IOwnable>();
    foreach (IOwnable ownableComponent in allIOwnableComponents)
    {
        if (ownableComponent.owner == player)
        {
            DeRez(ownableComponent.gameObject);
        }
    }

    Network.RemoveRPCs(player);
}

this is what my disconnect event looks like.

this is god damn annoying, what am i supposed to do ? pokemon exception handle all RPCs ?

Update:
ohgod, i can’t even try catch everything.
seems like it stacks the RPCs in a que and then executes them a couple of frames later or something.
i give up, there is no cure for this.

anybody knows some other networking library that doesn’t have this issue, but still is similar to unity (except ulink) ? >:C

Stuff like this is why I gave up and created TNet. -_-

i have this issue in my project too
anyone know how to fix this?

im having same problem. its now been some time since 1st reported any resolution, fix, workaround, change in my code i could do. or can i simply ignore it and other players its trying to do will occur for that rpc call so i dont have to worry. what im worrying about is that players after the failing one will not be updates.

so for example 5 players, 1 gets rpc no problem, 2 rpc call fails, and 3, 4, 5 do not get call at all cause exception is thrown and the code is exited…

so anyone know what will happen. nice if unity dev with access to source code will say what exactly will happen and what if anything we should do…

i mean we cant write code that catches the error check one player failed and then reissue the call for remaining. we r not given that level of control. and we dont know which one it fails at the api dont say…

it would be nice if rpc call would continue after ones that fail and send to all players… so in my example when 2 fails it just goes on to 3,4,5 and even if if it then did 3 and 4 failed it just went to 5…ect

one thing i could do my oen all/other by just looping around myself and issue the call to each player n if any fail catching and continuing the loop…

Yep, can we get that kind of info ? Would the RPC que continue to execute once one has failed due to player disconnect ?
I find it kinda hard to check that myself, but I guess it does due to UDP nature of raknet.