Still seeing timeouts after setting IsMessageQueueRunning to false

Options
I'm working on a VR app using photon for networking, and having disconnect issues on load. based on the official documentation at the bottom of the page on:
https://doc.photonengine.com/en-us/pun/current/troubleshooting/analyzing-disconnects#tweak_resends

it looks like once IsMessageQueueRunning is set to false, photon spins up a background tread to listen to events while a blocking load happens, then setting IsMessageQueueRunning will resume normal processing.

Every time I see:

Receiving failed. SocketException: ConnectionReset
UnityEngine.Debug:LogError(Object)
Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Core/Plugins/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1835)
ExitGames.Client.Photon.<>c__DisplayClass101_0:b__0()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Core/Plugins/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)


followed by

UnityEngine.Debug:LogWarningFormat(String, Object[])
NetworkConnectionManager:OnDisconnected(DisconnectCause) (at Assets/Core/Main/NetworkConnectionManager.cs:103)
Photon.Realtime.ConnectionCallbacksContainer:OnDisconnected(DisconnectCause) (at Assets/Core/Plugins/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3253)
Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode) (at Assets/Core/Plugins/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2382)
ExitGames.Client.Photon.<>c__DisplayClass102_0:b__0()
ExitGames.Client.Photon.TPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Core/Plugins/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)

Comments

  • In ChatClient.cs these comments exist:

    /// Defines if a background thread will call SendOutgoingCommands, while your code calls Service to dispatch received messages. ///
    /// The benefit of using a background thread to call SendOutgoingCommands is this:
    ///
    /// Even if your game logic is being paused, the background thread will keep the connection to the server up.
    /// On a lower level, acknowledgements and pings will prevent a server-side timeout while (e.g.) Unity loads assets.
    ///
    /// Your game logic still has to call Service regularly, or else incoming messages are not dispatched.
    /// As this typicalls triggers UI updates, it's easier to call Service from the main/UI thread.
    ///

    those comments conflict with the wording on:

    https://doc.photonengine.com/en-us/pun/current/troubleshooting/analyzing-disconnects#tweak_resends

    Which States:

    PUN implements the Service calls for you in intervals.

    However, Unity won't call Update while it's loading scenes and assets or while you drag a standalone-player's window.

    To keep the connection while loading scenes, you should set PhotonNetwork.IsMessageQueueRunning = false.

    Pausing the message queue has two effects:

    A background thread will be used to call SendOutgoingCommands while Update is not called. This keeps the connection alive, sending acknowledgements only but no events or operations (RPCs or sync updates). Incoming data is not executed by this thread.
    All incoming updates are queued. Neither RPCs are called, nor are observed objects updated. While you change the level, this avoids calling RPCs in the previous one.
    If you use our Photon Unity SDK, you probably do the Service calls in some MonoBehaviour Update method.

    To make sure Photon client's SendOutgoingCommands is called while you load scenes, implement a background thread. This thread should pause 100 or 200 ms between each call, so it does not take away all performance.


    digging through the code it looks like the client thread to do this isn't provided by photon, or any example of a suggested way to do this, and the documentation on analyzing-disconnects is just written in a confusing way.
  • Tobias
    Options
    To start this: Which version of PUN are you using?
    There was a bug with TCP connections (which you apparently use), that could disconnect even though the client attempted to keep the connection (using said thread). Depending on which version you use, you may be affected by that and an update helps.

    Are you using Chat as well? Cause when you point to the ChatClient, that's part of another API, which is not entirely the same as PUN (ofc). It doesn't look like the ChatClient is mentioned in the disconnect error messages.

    How long are your loading times? You set IsMessageQueueRunning to false and then load with Unity's API? Or what are you doing?