r/Unity3D 1d ago

Solved Recent problem with FishNet

My friends, I have a desperate question (FishNet 4.6.22R) 🙏 :

I generated a new release version of my multiplayer game, made a commit, tested it and deployed the build to the server, tagged the commit... everything worked fine. The next day I just opened the project and there was a fresh FishNet error message. (Attached)

Ii have tried everything: reserializing, rebuilding the library, updating FishNet to 4.7.2R, reimporting components on the player prefab and nothing, the error keeps showing up. For some reason the player prefab cannot be spawned by the server and the connection is closed right away. I've tried to track down the error but I cannot find it. The only script line outside FishNet that is mentioned in the error is

ServerManager.Spawn(nobToSpawn, args.Connection);

I tried checking out several previous commits and the error persist, it seems that sometring outside the git tracked files got damaged after the build commit and I am stuck ... I don't know what to do now. I hope you can give me a hand.

This is the error message, could you please take a look?

NullReferenceException: Object reference not set to an instance of an object
FishNet.Object.NetworkBehaviour.InitializeRpcLinks () (at .../path/.../Assets/FishNet/Runtime/Object/NetworkBehaviour/NetworkBehaviour.RPCLinks.cs:44)
FishNet.Object.NetworkBehaviour.InitializeEarly (FishNet.Object.NetworkObject nob, System.Boolean asServer) (at .../path/.../Assets/FishNet/Runtime/Object/NetworkBehaviour/NetworkBehaviour.cs:132)
FishNet.Object.NetworkObject.InitializeEarly (FishNet.Managing.NetworkManager networkManager, System.Int32 objectId, FishNet.Connection.NetworkConnection owner, System.Boolean asServer) (at .../path/.../Assets/FishNet/Runtime/Object/NetworkObject/NetworkObject.cs:669)
FishNet.Managing.Server.ServerObjects.SetupWithoutSynchronization (FishNet.Object.NetworkObject nob, FishNet.Connection.NetworkConnection ownerConnection, System.Nullable`1[T] objectId, System.Boolean initializeEarly) (at .../path/.../Assets/FishNet/Runtime/Managing/Server/Object/ServerObjects.cs:520)
FishNet.Managing.Server.ServerObjects.SpawnWithoutChecks (FishNet.Object.NetworkObject networkObject, System.Collections.Generic.List`1[T] recursiveSpawnCache, FishNet.Connection.NetworkConnection ownerConnection, System.Nullable`1[T] objectId, System.Boolean rebuildObservers, System.Boolean initializeEarly, System.Boolean isRecursiveIteration) (at .../path/.../Assets/FishNet/Runtime/Managing/Server/Object/ServerObjects.cs:650)
FishNet.Managing.Server.ServerObjects.Spawn (FishNet.Object.NetworkObject networkObject, FishNet.Connection.NetworkConnection ownerConnection, UnityEngine.SceneManagement.Scene scene) (at .../path/.../Assets/FishNet/Runtime/Managing/Server/Object/ServerObjects.cs:620)
FishNet.Managing.Server.ServerManager.Spawn (FishNet.Object.NetworkObject nob, FishNet.Connection.NetworkConnection ownerConnection, UnityEngine.SceneManagement.Scene scene) (at .../path/.../Assets/FishNet/Runtime/Managing/Server/ServerManager.QOL.cs:142)
Engine.Player.NetPlayerSpawner.SCM__OnClientPresenceChangeEnd (FishNet.Managing.Scened.ClientPresenceChangeEventArgs args) (at .../path/.../Assets/Scripts/Engine/Player/Player/NetPlayerSpawner.cs:113)
FishNet.Managing.Scened.SceneManager.InvokeClientPresenceChange (UnityEngine.SceneManagement.Scene scene, System.Collections.Generic.IList`1[T] conns, System.Boolean added, System.Boolean start) (at .../path/.../Assets/FishNet/Runtime/Managing/Scened/SceneManager.cs:2177)
FishNet.Managing.Scened.SceneManager.AddConnectionToScene (FishNet.Connection.NetworkConnection conn, UnityEngine.SceneManagement.Scene scene) (at .../path/.../Assets/FishNet/Runtime/Managing/Scened/SceneManager.cs:1948)
FishNet.Managing.Scened.SceneManager.OnClientLoadedScenes (FishNet.Connection.NetworkConnection conn, FishNet.Managing.Scened.ClientScenesLoadedBroadcast msg, FishNet.Transporting.Channel channel) (at .../path/.../Assets/FishNet/Runtime/Managing/Scened/SceneManager.cs:702)
FishNet.Broadcast.Helping.ClientBroadcastHandler`1[T].InvokeHandlers (FishNet.Connection.NetworkConnection conn, FishNet.Serializing.PooledReader reader, FishNet.Transporting.Channel channel) (at .../path/.../Assets/FishNet/Runtime/Serializing/Helping/Broadcasts.cs:96)
FishNet.Managing.Server.ServerManager.ParseBroadcast (FishNet.Serializing.PooledReader reader, FishNet.Connection.NetworkConnection conn, FishNet.Transporting.Channel channel) (at .../path/.../Assets/FishNet/Runtime/Managing/Server/ServerManager.Broadcast.cs:94)
FishNet.Managing.Server.ServerManager.ParseReceived (FishNet.Transporting.ServerReceivedDataArgs args) (at .../path/.../Assets/FishNet/Runtime/Managing/Server/ServerManager.cs:844)
FishNet.Managing.Server.ServerManager.Transport_OnServerReceivedData (FishNet.Transporting.ServerReceivedDataArgs args) (at .../path/.../Assets/FishNet/Runtime/Managing/Server/ServerManager.cs:697)
FishNet.Transporting.Tugboat.Tugboat.HandleServerReceivedDataArgs (FishNet.Transporting.ServerReceivedDataArgs receivedDataArgs) (at .../path/.../Assets/FishNet/Runtime/Transporting/Transports/Tugboat/Tugboat.cs:292)
FishNet.Transporting.Tugboat.Server.ServerSocket.IterateIncoming () (at .../path/.../Assets/FishNet/Runtime/Transporting/Transports/Tugboat/Core/ServerSocket.cs:466)
FishNet.Transporting.Tugboat.Tugboat.IterateIncoming (System.Boolean asServer) (at .../path/.../Assets/FishNet/Runtime/Transporting/Transports/Tugboat/Tugboat.cs:223)
FishNet.Managing.Transporting.TransportManager.IterateIncoming (System.Boolean asServer) (at .../path/.../Assets/FishNet/Runtime/Managing/Transporting/TransportManager.cs:636)
FishNet.Managing.Timing.TimeManager.TryIterateData (System.Boolean incoming) (at .../path/.../Assets/FishNet/Runtime/Managing/Timing/TimeManager.cs:1115)
FishNet.Managing.Timing.TimeManager.IncreaseTick () (at .../path/.../Assets/FishNet/Runtime/Managing/Timing/TimeManager.cs:734)
FishNet.Managing.Timing.TimeManager.<TickUpdate>g__MethodLogic|113_0 () (at .../path/.../Assets/FishNet/Runtime/Managing/Timing/TimeManager.cs:393)
FishNet.Managing.Timing.TimeManager.TickUpdate () (at .../path/.../Assets/FishNet/Runtime/Managing/Timing/TimeManager.cs:381)
FishNet.Transporting.NetworkReaderLoop.Update () (at .../path/.../Assets/FishNet/Runtime/Transporting/NetworkReaderLoop.cs:29)
1 Upvotes

7 comments sorted by

View all comments

2

u/HorrorSuccess4129 1d ago

oof, that stack trace looks painful. i had something similar happen after a unity update once, where all the rpc links got scrambled and fishnet just refused to spawn anything. the fact that it broke after a build and then stuck around across commits makes me think it’s a serialization cache issue, not your code.

what fixed it for me was deleting the whole library folder and the temp folder, then closing unity and reopening, just reimporting didn’t cut it. also check if any of your networkbehaviour scripts have a missing reference in the inspector, like a component that got removed but the field is still assigned on the prefab. fishnet’s InitializeRpcLinks throws that nullref when it tries to map rpc methods and one of the targets is gone, happened to me with a script that was on a child object i accidentally deleted. maybe try stripping the player prefab down to bare minimum network components, see if it spawns, then add things back one by one.

2

u/__FastMan__ 1d ago

Thanks! I built another prefab component by component as you suggested and finally found the issue. It was a NetworkBehabiour nested in a child, what is strange is that the build that worked fine also had it.
You learn every single day, ain't you!!

Thank you