question

Tom Cosaert avatar image
Tom Cosaert asked

Local ExecuteFunction redirection for local debugging broken in NuGet PlayFabAllSDK 1.127.220718?

Some background: for the last couple of months, we've been successfully using Azure Functions v4 with .NET isolation and .NET 6 for our back-end functions to be called by PlayFab via ExecuteFunction calls.

However, upgrading the PlayFabAllSDK NuGet from 1.108.220118 to any later version (e.g. the next 1.127.220718, or the latest 1.133.220816) seems to break the local debugging functionality.

Upgrading PlayFabAllSDK NuGet package

After upgrading the NuGet package all ExecuteFunction calls issued will directly go to PlayFab instead of the API running locally, bypassing the fact that there’s a "playfab.local.settings.json" file in the working directory containing an API redirection, as described in the documentation:

{
  "LocalApiServer": "http://localhost:7071/api/"
}

Note: although too general for our use, putting the "playfab.local.settings.json" file in "%Temp%" doesn't work anymore neither after the upgrade, as it does before.

This has been working fine for the past couple of months. Upgrading the NuGet package to the next version 1.127.220718 breaks the local debugging functionality. Downgrading back to 1.108.220118 restores working condition.

The documentation mentions no changes in how to allow local debugging. Has this been changed nonetheless or is this a bug?

sdks
10 |1200

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

Tom Cosaert avatar image
Tom Cosaert answered

We now moved away from using the "playfab.local.settings.json" file in non-Unity projects and simply configure the local PlayFab API server in our own appsettings.json file, then set it accordingly at run-time:

PlayFabSettings.LocalApiServer =
    !string.IsNullOrEmpty(_settings.LocalApiServer)
        ? _settings.LocalApiServer 
        : null;

This is an acceptable work-around for us. It's just strange that the documented way of configuring it doesn't seem to work anymore as it did before...

10 |1200

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

Xiao Zha avatar image
Xiao Zha answered

I have updated the PlayFabAllSDK to the version 1.127.220718 in my project, but the local debugging progress is working fine. Are you using Unity to call ExecuteFunction? If so, according to the source code here, if the "playfab.local.settings.json" file has been set correctly, it should go to local debugging progress. Can you add a break point here to see if the LocalApiServer URI in the "playfab.local.settings.json" file has been read correctly?

10 |1200

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

Tom Cosaert avatar image
Tom Cosaert answered

TL;DR No problems in Unity, only when using PlayFabAllSDK NuGet package version 1.127.220718 or higher in a regular .NET 6 project.

The implementation causing issues here is a standalone tool targeting .NET 6 for rapid testing of PlayFab functions during development of the back-end.

As a minimal proof of unexpected behavior, see the example attached: playfablocalapiservertest.zip

I simply created a blank new .NET 6 console project, added the latest (1.133.220816) PlayFabAllSDK NuGet package to it, dropped the code below in Program.cs and added a "playfab.local.settings.json" file in "%Temp%".

For completeness, I also added one to the project as well to have it automatically copied over to the output directory (working directory) upon building but you can of course even omit this step.

Code:

using PlayFab;

Console.Write($"PlayFab SDK {PlayFabSettings.SdkVersion} LocalApiServer: {PlayFabSettings.LocalApiServer}");

Output (depending on the PlayFabAllSDK NuGet package version of installed):

PlayFabAllSDK 1.108.220118 LocalApiServer: "http://localhost:7071/api/"
PlayFabAllSDK 1.127.220718 LocalApiServer: "" (null)
...
PlayFabAllSDK 1.133.220816 LocalApiServer: "" (null)

As a temporary work-around, I added a configuration setting, so I can set it from code:

if (_settings.UseLocalPlayFabApiServer)
    PlayFabSettings.LocalApiServer = "http://localhost:7071/api/";

Nonetheless, the behavior described above is unexpected and contrary to the documentation.

In comparison, in Unity, using the latest (2.146.220816) UnitySDK.unitypackage, there's no issue when dropping a "playfab.local.settings.json" file in "%Temp%". It uses the local API server as expected.

Code:

Debug.Log($"PlayFab SDK {PlayFabSettings.SdkVersion} LocalApiServer: {PlayFabSettings.LocalApiServer}");

Output:

PlayFab SDK 2.146.220816 LocalApiServer: http://localhost:7071/api/

So no problems in Unity, only when using PlayFabAllSDK NuGet package version 1.127.220718 or higher in a regular .NET 6 project.


10 |1200

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

Tom Cosaert avatar image
Tom Cosaert answered

Update on the bug reported above:

...

PlayFab SDK 1.134.220829 LocalApiServer: 

PlayFab SDK 1.135.220908 LocalApiServer: PlayFab SDK 1.138.220926 LocalApiServer: http://localhost:7071/api/

So it seems this was finally fixed in 1.138.220926.

Unfortunately, in that version, the work-around mentioned above (and actually more flexible way of setting this) does no longer work.

Property or indexer 'PlayFabSettings.LocalApiServer' cannot be assigned to -- it is read only

So we can no longer set this dynamically at run-time and need to revert to updating the playfab.local.settings.json file again, and then restarting the application?

Can you please change PlayFab.PlayFabSettings from

public static string LocalApiServer => PlayFabUtil.GetLocalSettingsFile().LocalApiServer;

to this?

public static string LocalApiServer { get; set; } = PlayFabUtil.GetLocalSettingsFile().LocalApiServer;
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.