Photon Realtime SDK MissingReferenceException

I can reliably reproduce this exception in any project using the Photon Realtime SDK.


  1. Connect to name server
  2. Ping regions
  3. Connect to best region
  4. Call LoadBalancingClient.Disconnect
  5. Re-connect to name server
  6. Ping regions = MissingReferenceException

Photon Realtime Version 4.1.6.22 (21. December 2022 - rev6637)

Stack Trace:

MissingReferenceException: The object of type 'MonoBehaviourEmpty' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Photon.Realtime.MonoBehaviourEmpty.SelfDestroy () (at Assets/Photon/PhotonRealtime/Code/RegionHandler.cs:779)
Photon.Realtime.RegionHandler.PingMinimumOfRegions (System.Action`1[T] onCompleteCallback, System.String previousSummary) (at Assets/Photon/PhotonRealtime/Code/RegionHandler.cs:243)
ProjectName.MatchmakingPhotonRealtime.Photon.Realtime.IConnectionCallbacks.OnRegionListReceived (Photon.Realtime.RegionHandler regionHandler) (at Assets/com.ProjectName.matchmaking.photonrealtime/Runtime/MatchmakingPhotonRealtime.cs:93)
Photon.Realtime.ConnectionCallbacksContainer.OnRegionListReceived (Photon.Realtime.RegionHandler regionHandler) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:4133)
Photon.Realtime.LoadBalancingClient.OnOperationResponse (ExitGames.Client.Photon.OperationResponse operationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2820)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:872)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:577)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1771)
ProjectName.MatchmakingPhotonRealtime.ProjectName.IMatchmaking.ReadIncomingMessages () (at Assets/com.ProjectName.matchmaking.photonrealtime/Runtime/MatchmakingPhotonRealtime.cs:62)
ProjectName.PlayerLoop.OnPreUpdate () (at Assets/com.ProjectName.playerloop/Runtime/PlayerLoop.cs:93)

Code that causes the exception:


Comments