question

contact-2 avatar image
contact-2 asked

Unity Integration - LoginWithCustomID not working

Hi,

I followed the Getting Started With PlayFab tutorial but I keep getting this error when I try to login with a custom ID:

PlayFabError(ServiceUnavailable, java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 11289): connect failed: ECONNREFUSED (Connection refused), 400 BadRequest)
  1. Do I need to link the game to the title ID somehow or to my studio?
  2. Do I need to define something in the manifest?
  3. Is this supposed to work in the Unity Editor? I tried on an Android device as well.

This is my code:

using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;

public class PlayFabManager : MonoBehaviour {

    public string UserId {
        get;
        private set;
    }

    public bool IsLoggedIn {
        get {
            return PlayFabClientAPI.IsClientLoggedIn();
        }
    }

    protected void Awake() {
        PlayFabSettings.TitleId = Config.PLAY_FAB_TITLE_ID;
    }

    protected void Start() {
        LoginWithDeviceID();
    }


    private void LoginWithDeviceID() {
        if (IsLoggedIn) return;

        var request = new LoginWithCustomIDRequest {
            TitleId = Config.PLAY_FAB_TITLE_ID,
            CreateAccount = true,
            CustomId = "8fa79815413d472d" // Just a temp value for testing.
        };

        PlayFabClientAPI.LoginWithCustomID(request, OnLoggedIn, OnLoginError);
    }

    private void OnLoggedIn(LoginResult result) {
        UserId = result.PlayFabId;
    }

    private static void OnLoginError(PlayFabError error) {
        Debug.LogError("Error logging in player with custom ID:");
        Debug.LogError(error);
    }
}

BTW, error.ErrorDetails is null.

Thanks!

Authentication
10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

What is your Title ID set to in PlayFabSettings?

4 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.

contact-2 avatar image contact-2 commented ·

If the integration is as simple as I think it is, anyone with the title ID can spam our title, right?

Anyway it's B99D

0 Likes 0 ·
brendan avatar image brendan contact-2 commented ·

Yes and no. The Custom ID login is not secure, so you should take care never to expose these IDs to players, as a hacked client could use it to log into another player's account. As to "spamming" though, we designed out system to have protections against excessive calls, specifically to prevent that sort of behavior. If you're keeping the Custom IDs private and are using a good algorithm for generation (like a GUID), it's unlikely that a player could "guess" another player's ID.

For your specific issue though, I'm not seeing these calls making it to our service for your title - which makes sense, since the error in question is that you're failing on a localhost connection. How exactly is your testing environment and project set up? Can you try running one of the samples from our Git projects unmodified (apart from the Title ID), to see what you can see?

1 Like 1 ·
contact-2 avatar image contact-2 brendan commented ·

Strange, I run the PrizeWheelRecipe and it worked straight away.

I now tested my project and it suddenly works... Is it possible that it takes time until the login calls start working?

Thanks!

0 Likes 0 ·
Show more comments

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.