Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug [FishNet] RPC error after upgrading

Discussion in 'Multiplayer' started by Crzed, Feb 11, 2024.

  1. Crzed

    Crzed

    Joined:
    Oct 19, 2013
    Posts:
    23
    I recently updated my project to the latest version of Fishnet and am working through some issues.
    I upgraded by deleting my previous FishNetworking folder and adding the latest from the asset store (I was on a version that was at least a year old).

    One of my targetRPCs, and probably any targetRpc, is failing now. When I set a breakpoint and step through the code, NetworkConnectionBuffer.cs has an empty _toClientBundles object when referencing it in the SendToClient() method, so the send is failing.

    The TargetRPC in question is this:
    Code (CSharp):
    1.     [TargetRpc]
    2.     public void RpcShowTriggeredCard(NetworkConnection conn, CardPOJO card, int tileTarget)
    3.     {
    4.      ....
    5. }



    I verified that it has a valid NetworkConnection object and other params.

    This creates the following stacktrace:

    Code (CSharp):
    1. ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <7e05db41a20b45108859fa03b97088d4>:0)
    4. FishNet.Connection.NetworkConnection.SendToClient (System.Byte channel, System.ArraySegment`1[T] segment, System.Boolean forceNewBuffer, FishNet.Object.DataOrderType orderType) (at Assets/FishNet/Runtime/Connection/NetworkConnection.Buffer.cs:74)
    5. FishNet.Managing.Transporting.TransportManager.SendToClient (System.Byte channelId, System.ArraySegment`1[T] segment, FishNet.Connection.NetworkConnection connection, System.Int32 requiredSplitMessages, System.Int32 maxSplitMessageSize, FishNet.Object.DataOrderType orderType) (at Assets/FishNet/Runtime/Managing/Transporting/TransportManager.cs:419)
    6. FishNet.Managing.Transporting.TransportManager.SendToClient (System.Byte channelId, System.ArraySegment`1[T] segment, FishNet.Connection.NetworkConnection connection, System.Boolean splitLargeMessages, FishNet.Object.DataOrderType orderType) (at Assets/FishNet/Runtime/Managing/Transporting/TransportManager.cs:408)
    7. FishNet.Object.NetworkBehaviour.SendTargetRpc (System.UInt32 hash, FishNet.Serializing.PooledWriter methodWriter, FishNet.Transporting.Channel channel, FishNet.Object.DataOrderType orderType, FishNet.Connection.NetworkConnection target, System.Boolean excludeServer, System.Boolean validateTarget) (at Assets/FishNet/Runtime/Object/NetworkBehaviour.RPCs.cs:341)
    8. PlayersCards.RpcWriter___Target_RpcShowTriggeredCard_2298291391 (FishNet.Connection.NetworkConnection conn, CardPOJO card, System.Int32 tileTarget) (at <e651ed62a25a4a4fa6759a5486af8ad4>:0)
    9. PlayersCards.RpcShowTriggeredCard (FishNet.Connection.NetworkConnection conn, CardPOJO card, System.Int32 tileTarget) <0x2ba9af6ade0 + 0x0006a> in <e651ed62a25a4a4fa6759a5486af8ad4>:0
    10. PlayersCards.RpcShowTriggeredCard (System.Int32 ConnectionId, CardPOJO card, System.Int32 tileTarget) (at Assets/Script/Cards/PlayersCards.cs:259)
    Anyone have an idea what I'm missing? This was working flawlessly before upgrading.
     
  2. Crzed

    Crzed

    Joined:
    Oct 19, 2013
    Posts:
    23
    In my case, it was because I was referencing the NetworkConnection objects from ClientManager.Clients. Changing it to use ServerManager.Clients. I am unsure why the connections stored in clientManager is now missing the toClientBundles in the newer fishnet version, but okay...
     
  3. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    383
    ToClientBundles was never exposed, unless perhaps it was unintentionally in an extremely old release.

    Can you elaborate a little more please, just want to make sure you're on the right path.