FishNet icon indicating copy to clipboard operation
FishNet copied to clipboard

Exception thrown, if Wi-Fi loses connection after a broadcast is sent.

Open maxgmer opened this issue 1 year ago • 0 comments

Important

When I lost Wi-Fi connection after sending a broadcast, exceptions flooded the logs and it didn't recover after I reconnected.

Here is the first exception I got:

NullReferenceException: Object reference not set to an instance of an object
LiteNetLib.NetManager.RemovePeerFromSet (LiteNetLib.NetPeer peer) (at Assets/FishNet/Runtime/Transporting/Transports/Tugboat/LiteNetLib/NetManager.HashSet.cs:171)
LiteNetLib.NetManager.RemovePeerInternal (LiteNetLib.NetPeer peer) (at Assets/FishNet/Runtime/Transporting/Transports/Tugboat/LiteNetLib/NetManager.HashSet.cs:152)
LiteNetLib.NetManager.RemovePeer (LiteNetLib.NetPeer peer) (at Assets/FishNet/Runtime/Transporting/Transports/Tugboat/LiteNetLib/NetManager.HashSet.cs:146)
LiteNetLib.NetManager.ProcessEvent (LiteNetLib.NetEvent evt) (at Assets/FishNet/Runtime/Transporting/Transports/Tugboat/LiteNetLib/NetManager.cs:513)
LiteNetLib.NetManager.PollEvents (System.Int32 maxProcessedEvents) (at Assets/FishNet/Runtime/Transporting/Transports/Tugboat/LiteNetLib/NetManager.cs:1501)
FishNet.Transporting.Tugboat.CommonSocket.PollSocket (LiteNetLib.NetManager nm) (at Assets/FishNet/Runtime/Transporting/Transports/Tugboat/Core/CommonSocket.cs:137)

"peer" is null on this line: int hashCode = peer.GetHashCode() & Lower31BitMask;

After the exception above the logs are flooded with this exception:

LockRecursionException: Recursive write lock acquisitions not allowed in this mode.
System.Threading.ReaderWriterLockSlim.TryEnterWriteLockCore (System.Threading.ReaderWriterLockSlim+TimeoutTracker timeout) (at <c100b493eaa84c73ac416f19c0437e7f>:0)
System.Threading.ReaderWriterLockSlim.TryEnterWriteLock (System.Threading.ReaderWriterLockSlim+TimeoutTracker timeout) (at <c100b493eaa84c73ac416f19c0437e7f>:0)
System.Threading.ReaderWriterLockSlim.TryEnterWriteLock (System.Int32 millisecondsTimeout) (at <c100b493eaa84c73ac416f19c0437e7f>:0)
System.Threading.ReaderWriterLockSlim.EnterWriteLock () (at <c100b493eaa84c73ac416f19c0437e7f>:0)
LiteNetLib.NetManager.RemovePeer (LiteNetLib.NetPeer peer) (at Assets/FishNet/Runtime/Transporting/Transports/Tugboat/LiteNetLib/NetManager.HashSet.cs:145)
LiteNetLib.NetManager.ProcessEvent (LiteNetLib.NetEvent evt) (at Assets/FishNet/Runtime/Transporting/Transports/Tugboat/LiteNetLib/NetManager.cs:513)

General Unity version: 2023.2.20f1 Fish-Networking version: 4.3.5

Description FishNet errors out after a broadcast is sent and then a connection with Wi-Fi is lost (at least on MacOS).

Replication Steps to reproduce the behavior:

  1. DoclientManager.Broadcast(yourBroadcast);
  2. When the runtime is stopped at this breakpoint, turn off Wi-Fi and continue execution.
  3. See the error

Expected behavior

  1. No errors are thrown, when Wi-Fi connection is lost.
  2. The broadcast is delivered after reconnection, if the connection timeout hasn't been reached yet (when connection is lost, but we reconnect quickly).

maxgmer avatar Jul 02 '24 08:07 maxgmer