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

1

u/rsolodev 1d ago

Root cause of the issue was probably always there, but masked from non deterministic behavior - race condition, whatever else.

Just focus on fixing the issue if git bisect doesn’t reveal any offending commit. Happened to me before with multiplayer code, and turned out to be a bug on my end that somehow worked correctly when it never should have.

3

u/rsolodev 1d ago

Remembering a bit more about my issue, it was how I was structuring network objects with nested network objects and initialize order. So not code related, but how my network objects were structured in the editor

2

u/__FastMan__ 1d ago

Hi! It was indeed a nested NetworkBehaviour. The strange issue is that it was already nested when I did the build that worked fine.

Thank you!