question

shirao-7239 avatar image
0 Votes"
shirao-7239 asked JiaYou-MSFT edited

Unity+PlayFab+AzureFunctionで関数アプリに接続出来ない

"Unity2020-3.8f1 , PlayFab:PlayFabUnitySDK 2.109.210521" を使用して、
'PlayFabClientAPI.LoginWithCustomID()' に成功したときに、
'PlayFabCloudScriptAPI.ExecuteFunction()' を使用して、
'関数アプリを呼び出そうとしてUnity上でエラーが出て失敗します。
エラーメッセージは次の通りです。
': Cannot connect to destination host'

'PlayFab Portal'への関数の登録と'Microsoft Azure' の portal への関数アプリの登録は、
vscode 上から完了済で行いました。


尚、一日前は動作が成功しておりました。関連コードと、設定は修正した覚えはありません。また、成功した方法を別のプロジェクトを新規作成して再現しようとしても、
成功しませんでした。

解決策はあるでしょうか?

windows-10-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HI shirao-7239,


1.Could you please share us how did you reproduce this issue?

2.Did you run specified application on Azure WVD VM and this application which has been developed by your company?

0 Votes 0 ·
shirao-7239 avatar image
0 Votes"
shirao-7239 answered
  1.  Void PlayFab.PlayFabCloudScriptAPI:ExecuteFunction (ExecuteFunctionRequest, Action`1, Action`1, Object, Dictionary`2)+0x72 at S:\pj\unity2020\PlayFabTest4\Assets\PlayFabSDK\CloudScript\PlayFabCloudScriptAPI.cs:[64:17-64:184]    C#
      Void PlayFabController:CallCSharpExecuteFunction ()+0xa4 at S:\pj\unity2020\PlayFabTest4\Assets\Scripts\PlayFabController.cs:[36:9-65:13]    C#
      Void PlayFabController:<Awake>b__0_0 (LoginResult)+0x39 at S:\pj\unity2020\PlayFabTest4\Assets\Scripts\PlayFabController.cs:[25:15-25:43]    C#
    

上記コールスタックにおいて、ExecuteFunction が失敗します。
これが再現といえます。

ExecuteFunction 内の localApiServerString が localhost になっていました。
そのことによって、下記の return を通過します。

   var localApiServerString = PlayFabSettings.LocalApiServer;
         if (!string.IsNullOrEmpty(localApiServerString))
         {
             var baseUri = new Uri(localApiServerString);
             var fullUri = new Uri(baseUri, "/CloudScript/ExecuteFunction".TrimStart('/'));
             PlayFabHttp.MakeApiCallWithFullUri(fullUri.AbsoluteUri, request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
             return;
         }

そうすると、"*azurewebsite.net" の url は使用されず、デバッグのための
localhost をセットアップする必要がありそうですが、

今回、localhost デバッグ環境で確認したいわけではないので、
localhost が適用されてしまう設定を無効、削除したいです。
なにか方法はあるでしょうか?

  1. yes 正確には個人で作成した Unity で作成したプログラムがクライアント
    で、PlayFab の情報を参照して、Azure のendpoint に接続しています。

Azure Function の endpoint は、 fiddler で確認すると http status code 200 です。

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

shirao-7239 avatar image
0 Votes"
shirao-7239 answered

試しに  PlayFabCloudScriptAPI.ExecuteFunction を元にして、

     public static void ExecuteFunction2(ExecuteFunctionRequest request, Action<ExecuteFunctionResult> resultCallback, Action<PlayFabError> errorCallback, object customData = null, Dictionary<string, string> extraHeaders = null)
     {
         var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer;
         var callSettings = PlayFabSettings.staticSettings;
         if (!context.IsEntityLoggedIn()) throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn,"Must be logged in to call this method");

if false

         var localApiServerString = PlayFabSettings.LocalApiServer;
         if (!string.IsNullOrEmpty(localApiServerString))
         {
             var baseUri = new Uri(localApiServerString);
             var fullUri = new Uri(baseUri, "/CloudScript/ExecuteFunction".TrimStart('/'));
             PlayFabHttp.MakeApiCallWithFullUri(fullUri.AbsoluteUri, request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
             return;
         }

endif


         PlayFabHttp.MakeApiCall("/CloudScript/ExecuteFunction", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings);
     }


というメソッドを追加して、これを 使用してみました。

そうしたら、'azure function' として定義した "*azurewebsite.net" endpoint を呼び出すことに成功しました。

ここで、質問が変化しますが、 上記のように、 ExecuteFunction2 を作成する方法ではなく、 PlayFabSettings.LocalApiServer の値をセットアップする方法はありますか?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JiaYou-MSFT avatar image
0 Votes"
JiaYou-MSFT answered JiaYou-MSFT edited

HI shirao-7239,

I found this topic issue not supported in this forum. I suggest we can post this issue in GitHub Support Community. There will more code lovers and staff help you. Thanks for your understanding.

GitHub Support Community
https://github.community/

============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.