question

brunosevero avatar image
brunosevero asked

Error 400: Cannot resolve destination host

Hello, I stuck with this error.

I'm trying to add PlayFab into a project. I'm using a project that I found in one of answer here (UnicornBattle) as base.

I wanna register an user. so I'm using "request=newRegisterPlayFabUserRequest()". but its failing an returning that destination error.

I couldn't figure out how to solve.

My classes

using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;

public class PlayFabAuthManager : MonoBehaviour
{

    public delegate void SuccessfulLoginHandler(string details);
    public delegate void FailedLoginHandler(string details);

    public static event SuccessfulLoginHandler OnLoginSuccess;
    public static event FailedLoginHandler OnLoginFail;

    public string AndroidId { get; private set; }
    public string IosId { get; private set; }
    public bool IsLoggedOut { get; }


    public static void RegisterNewPlayfabAccount(string email, string password)
    {
        //TODO
        // Validate email and password

        var request = new RegisterPlayFabUserRequest()
        {
            TitleId = PlayFabSettings.TitleId,
            Email = email,
            Password = password
        };

        PlayFabClientAPI.RegisterPlayFabUser(request, OnRegisterResult, OnLoginError);
    }

    private static void OnLoginError(PlayFabError error)
    {
        string errorMessage;
        if (error.Error == PlayFabErrorCode.InvalidParams && error.ErrorDetails.ContainsKey("Password"))
        {
            errorMessage = "Invalid Password";
        }
        else if (error.Error == PlayFabErrorCode.InvalidParams && error.ErrorDetails.ContainsKey("Username") || (error.Error == PlayFabErrorCode.InvalidUsername))
        {
            errorMessage = "Invalid Username";
        }
        else if (error.Error == PlayFabErrorCode.AccountNotFound)
        {
            errorMessage = "Account Not Found, you must have a linked PlayFab account. Start by registering a new account or using your device id";
        }
        else if (error.Error == PlayFabErrorCode.AccountBanned)
        {
            errorMessage = "Account Banned";
        }
        else if (error.Error == PlayFabErrorCode.InvalidUsernameOrPassword)
        {
            errorMessage = "Invalid Username or Password";
        }
        else
        {
            errorMessage = string.Format("Error {0}: {1}", error.HttpCode, error.ErrorMessage);
        }

        if (OnLoginFail != null)
        {
            OnLoginFail(errorMessage);
        }
        Debug.LogWarning(errorMessage);
    }

    private static void OnRegisterResult(RegisterPlayFabUserResult result)
    {
        if (OnLoginSuccess != null)
        {
            OnLoginSuccess("New Account Registered");
        }

        Debug.LogWarning("New Account Registered");
    }

}

using UnityEngine.UI;
using UnityEngine;

public class PlayFabLoginRegister : MonoBehaviour 
{
    [SerializeField] private GameObject logFeedback;
    [SerializeField] private Text feedbackText;
    [SerializeField] private Button loginButton;
    [SerializeField] private InputField loginEmail;
    [SerializeField] private InputField loginPassword;
    [SerializeField] private Button registerButton;
    [SerializeField] private InputField registerEmail;
    [SerializeField] private InputField registerPassword;


    private void Start()
    {
        registerButton.onClick.AddListener(RegisterNewAccount);
    }

    private void RegisterNewAccount()
    {
        PlayFabAuthManager.RegisterNewPlayfabAccount(registerEmail.text, registerPassword.text);
    }

    public void RegistrationFail()
    {
        //TODO
        logFeedback.SetActive(true);
    }
}
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.

brunosevero avatar image brunosevero commented ·

I forgot to mention I'm using Mac. Could be some missing configuration as well.

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

"Cannot resolve destination" is going to have to do with your network connection - an ISP issue, an overzealous firewall, etc. Please see this post for more on this issue:

https://community.playfab.com/questions/24083/serviceunavailablecannot-resolve-destination-host.html

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 ·

Also, check your PlayFabSettings to make sure you have your Title ID set correctly in your project (or in the Editor Extensions, if you're using it).

0 Likes 0 ·

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.