Stuck in Disconnecting state after iOS pause

Hi guys -

I have an issue where, under certain (but very reproduceable) conditions, if my iOS app is sent to background at the wrong time, when it wakes up the networkingPeer is stuck in the Disconnecting state FOREVER. No quantity of further calls to Disconnect or Connect fix it, killing the process is the only way I've found to reset it.

Per some tips I found elsewhere, my OnApplicationPause looks like this:
[code2=csharp]void OnApplicationPause(bool pause)
if (pause)
Application.LoadLevel(Application.loadedLevel); // triggers another call to Connect()

I've tried a few variations on this and it works about 95% of the time, but if I pause the app during the process of creating or joining a room, the bug is triggered and I am forever 'Disconnecting' after I resume. Further pause/resume cycles do not help, and my app is essentially useless after that.

What is the right approach to here? Is there a clean, safe way to completely reset the networkingPeer?




  • Tobias
    Obviously, it's possible to break the workflow of changing servers by pausing the app. On iOS, this means instant loss of the socket. Depending on how quickly the app gets active again, the client might recover the connection or needs a new one.
    I will have to take a look at that.

    As workaround, you could add this to NetworkingPeer:

    [code2=csharp]public void Disconnect(bool reset)

    if (reset)
    this.State = global::PeerState.Disconnected;

    Modify PhotonNetworking.Disconnect() to have the reset parameter, too.
    Call it with reset = true and it should reset the client's connection and relevant state.

    I didn't get to test this yet, so let me know if something is odd.
  • Thanks Tobias, but sadly no joy. I still get essentially the same

    "Connect() only works when disconnected. Current state: Disconnecting"

    message after using this version of Disconnect. Our app was supposed to launch this week and this is the last major bug. Is forcing the app to exit on pause the only reasonable solution in the near term?

  • Tobias
    I'm sorry I let you wait. Busy days.
    This didn't work? With reset = true?
    Can you elaborate on how you reproduce this case? Or provide a repro case even? By mail:

    Unless I can reproduce it, I can't promise much in terms of timing. I could work on it next week for sure but need a repro case.