Stuck on 'connecting', need to restart app

We have a worldwide matchmaking system which will give matches from other regions as well based on your ping. Sometimes when player has to change servers say from us to usw for example the client gets stuck on 'connecting' state. Can't connect to any server and can't disconnect because not connected. Client stays in this state forever where PhotonNetwork.connecting is true. You have to restart the app in order to clear this bug.

I've also noticed that you guys have many variables which should do the same thing but on some cases are not working correctly. For example PhotonNetwork.inRoom might be false but is still non-null. I had to change every "if( != null)" to "if(PhotonNetwork.inRoom)" to avoid errors.


  • punppis
    edited February 2017
    This is not a network issues since I've had tens of clients running on the same computer at the same time and some clients keep working correctly and some clients are facing this bug.

    Also sometimes when PhotonNetwork.connectedAndReady is true you still get "not connected to master server" errors when trying to join room.
  • Demetri
    edited February 2017
    Have the same problem. Application often stucks on connecting. This problem appeared several days ago and still is there. Here is stacktrace for this error:

    Operation failed: OperationResponse 227: ReturnCode: 32762 (Failed to get server instance.). Parameters: {} Server: MasterServer
    NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1532)
    PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:156)

    Application restarting helps.
    I hope my problem is not offtop
  • Hi @punppis, @Demetri,

    We had issues on EU cloud region that are now fixed.
    Please confirm that you are not seeing those errors again.
    I apologize about the inconvenience.
  • punppis
    edited February 2017
    Hi @JohnTube,

    sorry to say but we have been experiencing this for months. This is most likely a client bug where client thinks it's connecting but actually is not.

    1. Try to connect random ip without server running
    2. Client tries to connect for long time (~25sec)
    3. OnFailedToConnectToPhoton: DisconnectByClientTimeout
    4. Try to connect again but client stuck on connecting state

    void Connect()
        if(PhotonNetwork.connected || PhotonNetwork.connecting)
            Debug.LogError("Already connected or connecting to photon.");
            Debug.LogError(PhotonNetwork.connectionStateDetailed); // PeerCreated
            Debug.LogError(PhotonNetwork.connected); // False
            Debug.LogError(PhotonNetwork.connecting); // True
        	// this is a made up ip which does NOT have server running
        	PhotonNetwork.ConnectToMaster("", 5055, PhotonNetwork.PhotonServerSettings.AppID, ver);

    In this case you can stills sometimes connect even the 'connecting' variable is set to true. Sometimes you cannot and get "You're not disconnected". This is not expected behaviour at all.

    Clearly the 'connecting' is bugged. Any idea how to properly fix it?

        /// <summary>
        /// True when you called ConnectUsingSettings (or similar) until the low level connection to Photon gets established.
        /// </summary>
        public static bool connecting
            get { return networkingPeer.IsInitialConnect && !offlineMode; }
  • Hi @punppis,

    I see! Thank you for your report and useful information.
    We will investigate this and try to reproduce.
    For the mean time, please try this workaround (forcing disconnect in disconnect callbacks):
    void OnConnectionFail(){
    void OnFailedToConnectToPhoton(DisconnectCause cause){
  • @JohnTube,

    Disconnect() does not seem to work but PhotonNetwork.networkingPeer.IsInitialConnect = false works. Sometimes Disconnect does nothing and sometimes you get "Can't execute Disconnect() while not connected.".
  • JohnTube
    JohnTube mod
    edited February 2017
    I see. So to be clear, this issue happens only if first connection attempt fails (i.e. InitialConnect) or on every connection failure / unexpected disconnection (e.g. timeouts)? And explicit disconnect in normal workflow (calls to PhotonNetwork.Disconnect()) works as expected right?
  • Hi,

    Are you using some authentication in your connection process?

    you seem to be using the offline feature, can you explain how you work with the offline mode?