question

zrdeland avatar image
zrdeland asked

Unable to Connect to Photon Chat, Error Code: 32755

I have scoured through the forums and cannot resolve the "32755" error message when attempting to connect to Photon Chat .

I know I have to use the Chat ID provided by PlayFab Add-Ons and am doing so. I can connect the Photon Cloud, PlayFab and Facebook (login) with no errors. Players can even play games without connection errors.

Only the Chat ID appears to be bad or I am implementing it incorrectly. I have seen some people say pass the PlayFabID and other just a username. Neither have worked. Here is my latest version of the code.

PlayFabFacebookLogin.cs

private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult obj)
    {
        LogMessage("Photon token acquired: " + obj.PhotonCustomAuthenticationToken + "  Authentication complete.");


        //We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
        var customAuth = new AuthenticationValues { AuthType = CustomAuthenticationType.Custom };


        //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        customAuth.AddAuthParameter("user_id", PlayFabID);    // expected by PlayFab custom auth service


        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.AddAuthParameter("token", obj.PhotonCustomAuthenticationToken);


        //We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = customAuth;
        PhotonNetwork.AuthValues.UserId = PlayFabID; // this is important


        //Start chat service
        chatManager.InitChat(obj.PhotonCustomAuthenticationToken); //not sure if token was required but passed just in case
}

ChatManager.cs

public void InitChat(string token)
    {
        // In the C# SDKs, the callbacks are defined in the `IChatClientListener` interface. 
        // In the demos, we instantiate and use the ChatClient class to implement the IChatClientListener interface. 
        chatClient = new ChatClient(this);
        ChatStatus.text = "Initiating chat client...";
        // Set your favourite region. "EU", "US", and "ASIA" are currently supported.
        chatClient.ChatRegion = "US";
        
        ExitGames.Client.Photon.Chat.AuthenticationValues authVals = new ExitGames.Client.Photon.Chat.AuthenticationValues(playFabFB.PlayFabID);
        authVals.AuthType = ExitGames.Client.Photon.Chat.CustomAuthenticationType.Custom;
        authVals.AddAuthParameter("userid", playFabFB.PlayFabID);
        authVals.AddAuthParameter("token", token);
        chatClient.AuthValues = authVals;
        
        chatClient.Connect(PhotonNetwork.PhotonServerSettings.ChatAppID, "1.0", authVals);
    }

Also, I tried running the Photon Chat Demo App (Unity) and it also returned the same error code "32755".

photonAuthentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

That error is means that there was an error with custom authentication. Which, in turn, would be due to a problem with the App ID used for the title, in general. What are the Title ID and App ID you're using for this test?

6 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

zrdeland avatar image zrdeland commented ·

Title: 9BFE

AppID: b4de8ae8-3ff3-4959-97d2-5eaaa46c25db

The screenshot below shows that I get a token and can even update this player's statistics without any errors until it tries to connect to Chat.

0 Likes 0 ·
chaterror.png (37.9 KiB)
brendan avatar image brendan zrdeland commented ·

That's actually a Photon Realtime App ID, not Photon Chat. Can you try switching to the other one (https://developer.playfab.com/en-us/9BFE/addons/Photon)?

0 Likes 0 ·
zrdeland avatar image zrdeland brendan commented ·

Switching them resulted in the same 32755 error. In both my app and in the Photon Chat demo app. I have attached a screenshot of the Add-On settings and the Unity settings.

0 Likes 0 ·
Show more comments
zrdeland avatar image zrdeland commented ·

Is there something wrong with the TitleID or AppID?

0 Likes 0 ·
brendan avatar image brendan zrdeland commented ·

The App IDs appear to have been entered correctly, but the Exit Games folks should be able to help you further with the error message coming back from their service.

0 Likes 0 ·
zrdeland avatar image
zrdeland answered

I realized that I was not actually attempting to connect to the Photon Cloud in the original code I submitted. I decided to start from scratch using the tutorial swapping out "LoginWithCustomID" with "LoginWithFacebook" (and appropriate callbacks).

For some reason that has resolved the photon cloud connection error. The chat code still triggers the same error but at least there is some progress. Assistance with the chat connection would be greatly appreciated. Below is the altest working code for Photon Cloud.

public void Start()
    {
        // This call is required before any other calls to the Facebook API. We pass in the callback to be invoked once initialization is finished
        FB.Init(OnFacebookInitialized);
    }


    public void LoginButtonClick()
    {
        FB.LogInWithReadPermissions(new List<string> { "user_friends" }, OnFacebookLoggedIn);
    }


    private void OnFacebookInitialized()
    {

        // Once Facebook SDK is initialized, display the correct screen
        if (FB.IsLoggedIn)
            AlreadyLoggedInWithFacebook();
        else
        {
            // We invoke basic login procedure and pass in the callback to process the result
            FB.LogInWithReadPermissions(new List<string> { "user_friends" }, OnFacebookLoggedIn);
        }
        
    }


    private void AlreadyLoggedInWithFacebook()
    {
        PlayFabClientAPI.LoginWithFacebook(new LoginWithFacebookRequest { CreateAccount = true, AccessToken = AccessToken.CurrentAccessToken.TokenString },
                OnPlayfabFacebookAuthComplete, OnPlayfabFacebookAuthFailed);
    }


    private void OnFacebookLoggedIn(ILoginResult result)
    {
        // If result has no errors, it means we have authenticated in Facebook successfully
        if (result == null || string.IsNullOrEmpty(result.Error))
        {
            //SetMessage("Facebook Auth Complete! Access Token: " + AccessToken.CurrentAccessToken.TokenString + "\nLogging into PlayFab...");


            /*
             * We proceed with making a call to PlayFab API. We pass in current Facebook AccessToken and let it create 
             * and account using CreateAccount flag set to true. We also pass the callback for Success and Failure results
             */
            PlayFabClientAPI.LoginWithFacebook(new LoginWithFacebookRequest { CreateAccount = true, AccessToken = AccessToken.CurrentAccessToken.TokenString },
                OnPlayfabFacebookAuthComplete, OnPlayfabFacebookAuthFailed);
        }
        else
        {
            // If Facebook authentication failed, we stop the cycle with the message
            Debug.Log("Facebook Auth Failed: " + result.Error + "\n" + result.RawResult);
        }
    }


    // When processing both results, we just set the message, explaining what's going on.
    private void OnPlayfabFacebookAuthComplete(LoginResult result)
    {
        //SetMessage("PlayFab Facebook Auth Complete.");


        if (FB.IsLoggedIn)
        {
            PlayFabID = result.PlayFabId;


            //Photon Authentication
            GetPhotonToken();
        }


    }


    void GetPhotonToken()
    {
        PlayFabClientAPI.GetPhotonAuthenticationToken(new GetPhotonAuthenticationTokenRequest()
        {
            PhotonApplicationId = PhotonNetwork.PhotonServerSettings.AppID
        }, AuthenticateWithPhoton, OnPlayFabError);
    }


    private void OnFBPlayfabError(PlayFabError obj)
    {
        Debug.Log("GetPhotonAuthenticationToken return error: "+obj.GenerateErrorReport());
    }


    /* This is the final and the simplest step.We create new AuthenticationValues instance.
    * This class describes how to authenticate a players inside Photon environment.
    */
    private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult obj)
    {
        LogMessage("Photon token acquired: " + obj.PhotonCustomAuthenticationToken + "  Authentication complete.");


        //We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
        var customAuth = new AuthenticationValues { AuthType = CustomAuthenticationType.Custom };


        //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        Debug.Log("Using PlayFabID: "+ PlayFabID);
        customAuth.AddAuthParameter("username", PlayFabID);    // expected by PlayFab custom auth service


        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.AddAuthParameter("token", obj.PhotonCustomAuthenticationToken);


        //We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = customAuth;
        PhotonNetwork.AuthValues.UserId = PlayFabID; // this is important


        PhotonNetwork.ConnectUsingSettings("1");


        //Start chat service
        chatManager.InitChat(PhotonNetwork.AuthValues);


        //update stats
        //statsManager.SetBasicStats();       
        statsManager.GetBasicStats();


        GetFacebookNameAndPicture();
        screenManager.DisplayMainMenuScreen();
    }
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

Again, given that the error is specific to a call you're making to the Photon service, your best bet will be to ask the team at Exit Games, as it's their product. You can reach them via their forums, here: http://forum.photonengine.com/

0 Likes 0 ·
Hamza Lazaar avatar image
Hamza Lazaar answered

Hi @zrdeland

Thank you for choosing Photon!

Please replace:

customAuth.AddAuthParameter("user_id",PlayFabID);

with

customAuth.AddAuthParameter("username",PlayFabID);

and

authVals.AddAuthParameter("userid", playFabFB.PlayFabID);

with

authVals.AddAuthParameter("username", playFabFB.PlayFabID);
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.