Code 32767 (Non token authentication is not allowed)

Options
Hello,

I'm working on a client's game that makes use of Photon. For the past months it's been working fine, but these last days I've been getting this error constantly :

`OperationResponse 230: ReturnCode: 32767 (Non token authentication is not allowed). Parameters: {} Server: GameServer Address: 92.38.154.73:5056`

After checking out months old commits, it seems the error also happens on these older commits (even though back then, the error did not happen at all).

So it seems that something changed on Photon's side, independant from our codebase, and is causing this error. Do you have any idea what it could be?

Pun version is 2.6, Photon lib is 4.1.2.7, we did not hit our CCU limit (only 2/20) and the app id is properly set in the Photon settings file.

Thanks in advance!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @LaP0573,

    Thank you for choosing Photon!

    Yes we disabled 'tokenless' authentication on the public cloud.
    Somehow you managed to make a client connect to Photon game server and try to authenticate without the token received on the master server before.
    Not sure what you are doing but it looks like you are using a modified PUN version or you are using it in an unexpected way that leads to this.
    If this is not the case, please send us an email to developer@photonengine.com with your AppId/AppVersion/Region and how to reproduce (minimal repro steps).
  • LaP0573
    Options
    JohnTube wrote: »
    Hi @LaP0573,

    Thank you for choosing Photon!

    Yes we disabled 'tokenless' authentication on the public cloud.
    Somehow you managed to make a client connect to Photon game server and try to authenticate without the token received on the master server before.
    Not sure what you are doing but it looks like you are using a modified PUN version or you are using it in an unexpected way that leads to this.
    If this is not the case, please send us an email to developer@photonengine.com with your AppId/AppVersion/Region and how to reproduce (minimal repro steps).

    Thank you for the answer! This makes a lot of sense. We currently allow both guest players and facebook-logged players, so this means that our guest players can no longer access the game right? Which would explain the issue.

    So this means that we now need to block guest players from playing online, and force them to login through facebook to play online? Is there no other way to allow those guests ?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2021
    Options
    No, this is a different thing.
    Photon internal authentication is different from custom authentication which is optional.
    Even "anonymous" users can connect fine as long as the authentication token is used (see below).

    Any client that connects to Photon NameServer should get an encrypted authentication or session token.
    This is then sent to MasterServer which in return refreshes the token and sends a new one back before joining a room.
    The new token is then used to authenticate on GameServer.
    Everytime the client switches servers the token is refreshed.
    The token is also refreshed inside a room after a while if you keep raising events.

    So the client is somehow not sending the mandatory required token as expected to the GameServer.
    The question is why?

    Do you connect via NameServer or to a MasterServer directly via its address?
  • LaP0573
    LaP0573
    edited April 2021
    Options
    JohnTube wrote: »
    No, this is a different thing.
    Photon internal authentication is different from custom authentication which is optional.
    Even "anonymous" users can connect fine as long as the authentication token is used (see below).

    Any client that connects to Photon NameServer should get an encrypted authentication or session token.
    This is then sent to MasterServer which in return refreshes the token and sends a new one back before joining a room.
    The new token is then used to authenticate on GameServer.
    Everytime the client switches servers the token is refreshed.
    The token is also refreshed inside a room after a while if you keep raising events.

    So the client is somehow not sending the mandatory required token as expected to the GameServer.
    The question is why?

    Do you connect via NameServer or to a MasterServer directly via its address?

    Thank you for taking the time to explain all that. I'm looking around the codebase to see where the issue might come from (it's a 2 years old sprawling codebase and I wasn't around back then, so it makes finding the source of the problem harder haha), and the connection seems to be made this way :
    if (m_isConnected || m_isConnecting || !InternetConnection.isConnected)
            {
                return;
            }
    
            if (!string.IsNullOrEmpty(BingoPlayer.localPlayer.photonID))
            {
                AuthenticationValues AuthValues = new AuthenticationValues();
                AuthValues.UserId = BingoPlayer.localPlayer.photonID;
    
                PhotonNetwork.AuthValues = AuthValues;
            }
    
            PhotonNetwork.GameVersion = Application.version;
            PhotonNetwork.ConnectUsingSettings();
    
            m_isConnecting = true;
    


    I've been around commenting various other calls to Photon (keeping this one), and I managed to bypass the crash by commenting a
    PhotonNetwork.LeaveRoom()
    
    , so the problem might be originating from there ? Is that not the correct way of doing it ?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2021
    Options
    It may not be directly related as usually a code that comes before PhotonNetwork.ConnectUsingSettings();
    means the client is still not connected and being 'initialized'.
    So it might be OK to set PhotonNetwork.AuthValues.
    But to be safe never set it unless it's null and instead try to set UserId directly?
    if (PhotonNetwork.AuthValues == null)
    {
      PhotonNetwork.AuthValues = new AuthenticationValues(BingoPlayer.localPlayer.photonID);
    }
    else 
    {
       PhotonNetwork.AuthValues = BingoPlayer.localPlayer.photonID;
    }
    

    But this might still not fix it.

    There is also another issue not directly related: it's about setting GameVersion:
    PhotonNetwork.ConnectUsingSettings() no longer takes gameVersion parameter. Instead the AppVersion parameter set from the Unity Editor in the PhotonServerSettings, AppSettings section is used as PhotonNetwork.GameVersion. If you want to set the PhotonNetwork.GameVersion from code you could either
    • set PhotonNetwork.GameVersion just after calling PhotonNetwork.ConnectUsingSettings()
    • set PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion before calling PhotonNetwork.ConnectUsingSettings()
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    I got a hint from @Tobias that if you use PUN 2.30 (latest as of today) you will get an error on the client if you try to authenticate without a token.
    also it may contain a fix of an edge/rare case where the token could be lost if you try to call connect multiple times.