question

bahamut06 avatar image
bahamut06 asked

System.Net.Http: The requested name is valid, but no data of the requested ty pe was found. (playfabapi.com:443)

Im trying to debug an Azure Function locally, calling it from Unity and im not sure if im doing it correctly. Everything runs fine on Azure but im unable to do it in local. I followed https://learn.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/local-debugging-for-cloudscript-using-azure-functions to prepare my local environment to debug these functions.

Im getting an exception on this line from the ExecuteFunctions.cs local file

using (var profileResponseMessage = await httpClient.PostAsync(getProfileUrl, profileRequestContent)) {

 // Execute the get entity profile request
             using (var profileResponseMessage =
                     await httpClient.PostAsync(getProfileUrl, profileRequestContent))
             {
                 using (var profileResponseContent = profileResponseMessage.Content)
                 {
                     string profileResponseString = await profileResponseContent.ReadAsStringAsync();
    
                     // Deserialize the http response
                     getProfileResponseSuccess =
                         PlayFabSimpleJson.DeserializeObject<PlayFabJsonSuccess<GetEntityProfileResponse>>(profileResponseString);
    
                     // Extract the actual get profile response from the deserialized http response
                     getProfileResponse = getProfileResponseSuccess?.data;
                 }
             }

Im not sure what im doing wrong. First thing i do is connect to PlayFab from unity to get the PlayFab entity from the user, and then i call the local function i want to debug but it doesnt even get to the actual function i want to debug as the intercepting ExecuteFunction.cs throws:

System.Private.CoreLib: Exception while executing function: ExecuteFunction. System.Net.Http: The requested name is valid, but no data of the requested ty

pe was found. (playfabapi.com:443). System.Net.Sockets: The requested name is valid, but no data of the requested type was found.

This is the unity code:

 public IEnumerator PostNewAccount()
     {
         PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest()
         {
             Entity = new PlayFab.CloudScriptModels.EntityKey()
             {
                 Id = PlayFabSettings.staticPlayer.EntityId, //Get this from when you logged in,
                 Type = PlayFabSettings.staticPlayer.EntityType, //Get this from when you logged in
             },
             FunctionName = "HelloWorld", //This should be the name of your Azure Function that you created.
             FunctionParameter = new Dictionary<string, object>() { { "inputValue", "Test" } }, //This is the data that you would want to pass into your function.
             GeneratePlayStreamEvent = false //Set this to true if you would like this call to show up in PlayStream
         }, (ExecuteFunctionResult result) =>
         {
             if (result.FunctionResultTooLarge ?? false)
             {
                 Debug.Log("This can happen if you exceed the limit that can be returned from an Azure Function, See PlayFab Limits Page for details.");
                 return;
             }
             Debug.Log($"The {result.FunctionName} function took {result.ExecutionTimeMilliseconds} to complete");
             Debug.Log($"Result: {result.FunctionResult.ToString()}");
         }, (PlayFabError error) =>
         {
             Debug.Log($"Opps Something went wrong: {error.GenerateErrorReport()}");
         });
         yield return WaitForExecution();
     }

And this is the Azure Function running in local

 public static class HelloWorld
 {
     [FunctionName("HelloWorld")]
     public static async Task Run(
         [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, ILogger log)
     {
         var context = await FunctionContext.Create(req);
         var playerId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId;
         await PlayerRepository.HelloWorld(context.AuthenticationContext, playerId);
     }
 }
CloudScript
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

·
Simon Cui avatar image
Simon Cui answered

Please check the getProfileUrl in await httpClient.PostAsync(getProfileUrl, profileRequestContent)). This issue could be caused by missing titleId in the URL, you may refer to this post: GetProfile using local azure cloud functions - Playfab Community.

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

dylan-1 avatar image dylan-1 commented ·

I also have this issue. I already have the correct syntax mentioned in the answer above. When debugging with a breakpoint, whatever happens below doesn't even matter much.

Here's what's interesting: Postman works np, but from Unreal creates this issue only (yes: The local redirect file was placed in %temp%). If Unreal calls live, it works np. I have a feeling that no one has been able to test successfully from Unreal.

0 Likes 0 ·
Simon Cui avatar image Simon Cui dylan-1 commented ·

Since you are using Unreal which is different from Unity that bahamut06 used, I am not sure if it is same issue. By the way, it worked when the local redirect file was placed in the "temp" folder which is "C:\Users\Administrator\AppData\Local\Temp" through my Unity test. You may debug your Unreal codes to see what is the real %Temp% folder that it directs.

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.