Expired Auth can not be regained

Options
Hi,
We have an IOS game and as nature of mobile, we have long time pauses between sessions. After one hour, I am getting AuthenticationTicketExpired from OnConnectionFail. We have a disconnect, connect mechanism working with OnConnectedToPhoton and OnDisconnectedFromPhoton. Normally I use PhotonNetwork.Reconnect(); method to reconnect but I realised when token is lost, I can not use this method.

So I use the method below :
    void OnConnectionFail(DisconnectCause cause)
    {
        log.ins.entermessage("connectionfailcause : " + cause);

        if (cause == DisconnectCause.AuthenticationTicketExpired)
            PhotonNetwork.ConnectUsingSettings("0.1");
    }
But this simply turns without response. I am trying to solve the problem for some days and it really gives me headache to wait one hour to wait for token to expire to debug.

My questions are :
- Is there a way that I can expire the token so I can debug directly?
- What am I doing wrong in my logic, is there an ideal way to solve this issue?

Thanks

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Sonnyboy,

    Thank you for choosing Photon!

    What PUN version do you use?
    Do you use Custom Authentication?

    We have added an internal event that auto refresh tokens to avoid expiration situations.
    This require client to be active (sending events) to server in order to receive the new token.

    - Is there a way that I can expire the token so I can debug directly?
    If you want to test and debug then you would have to self host a Photon Server and tweak the config.
    So your dev. environment will be Photon Server and then switch back to the Cloud.
    I will have to check how to configure token expiration settings for Photon Server though.

    - What am I doing wrong in my logic, is there an ideal way to solve this issue?
    Try updating your workaround as when OnConnectionFail is called client is not completely done with disconnection:
    void OnConnectionFail(DisconnectCause cause)
        {
            log.ins.entermessage("connectionfailcause : " + cause);
        }
    
    void OnDisconnectedFromPhoton()
        {
            DisconnectCause cause = PhotonNetwork.networkingPeer.DisconnectCause; // IIRC or cache it
            log.ins.entermessage("OnDisconnectedFromPhoton: " + cause);
    
            if (cause == DisconnectCause.AuthenticationTicketExpired)
                PhotonNetwork.ConnectUsingSettings("0.1");
        }