Azure PlayFab (NodeJS) with Unity Error

I got error while excuting metamask login with unity.

“Oops Something went wrong: /CloudScript/ExecuteFunction: The function ChallengeRequest was terminated after the maximum execution time limit: 10000ms”

I’m testing using azure Playfab (NodeJS) with unity. What’s the error?
I just followed https://docs.moralis.io/authentication-api/integrations/azure-playfab-nodejs-unity page.

And I used C# Playfab before. Is it deprecated?

it looks like it was not able to call ChallengeRequest, maybe a vpn issue or a network issue?
you get that error every time?

Yes. But when I use C# version, it works.

what is the difference in the request for when it work and when it doesn’t work? can you intercept the request that is made to check if there is a difference?

Did you resolve this?
I have the same issue.

Hi @SupDog

Would would more details on how to reproduce this error.
Can you once test the endpoint in docs using your API param values?

Thanks for the response.
I’m following this tutorial https://docs.moralis.io/authentication-api/integrations/azure-playfab-nodejs-unity

I get a Unity error which occurs after using the Connect button, scanning the QR code in MetaMask, then pressing the Connect button in MetaMask.
“Oops Something went wrong: /CloudScript/ExecuteFunction: The function ChallengeRequest was terminated after the maximum execution time limit: 10000ms”

I am reasonable new to some of these technologies and have started learning how to troubleshoot Azure Functions.
I can see this error in Azure Diagnostics for my Function App:
Moralis SDK Error: [C0009] Modules are started already. This method should be called only one time. at Core. (C:\home\site\wwwroot\node_modules@moralisweb3\common-core\lib\cjs\index.cjs:909:35) at step (C:\home\site\wwwroot\node_modules@moralisweb3\common-core\lib\cjs\index.cjs:81:23) at Object.next (C:\home\site\wwwroot\node_modules@moralisweb3\common-core\lib\cjs\index.cjs:62:53) at C:\home\site\wwwroot\node_modules@moralisweb3\common-core\lib\cjs\index.cjs:55:71 at new Promise () at __awaiter (C:\home\site\wwwroot\node_modules@moralisweb3\common-core\lib\cjs\index.cjs:51:12) at Core.start (C:\home\site\wwwroot\node_modules@moralisweb3\common-core\lib\cjs\index.cjs:903:57) at Object.start (C:\home\site\wwwroot\node_modules\moralis\lib\cjs\index.cjs:40:21) at Object. (C:\home\site\wwwroot\GetWalletNfts\index.js:5:9) at Module._compile (node:internal/modules/cjs/loader:1159:14)

The Moralis endpoint test appears to return a valid 201 response when I use my API key.

You can fix this error by using an if condition to check if moralis sdk was already started.

  if (!Moralis.Core.isStarted) {
    await Moralis.start({
      apiKey: process.env.API_KEY,
    });
  }
1 Like

Thank you, that helped a lot.

Making progress now, can see this error in my Azure Function Log stream:
MoralisError [Moralis SDK Error]: [C0005] Request contains unknown parameter: network. This operation supports the following parameters: domain, chainId, address, statement, uri, expirationTime, notBefore, resources, timeout

Hey @SupDog,

The error that you have there just indicates that you will not need network anymore as an input as other previous versions, you should remove it from your input when calling the API in Azure and it should work well

1 Like

Cheers, that worked.

I wound up having to make three changes to the Unity tutorial code to successfully authenticate.

  1. Added the if condition to check whether the Moralis SDK was already started (as suggested by @johnversus).
    I had to remove the await operator as this led me down a rabbit hole of new errors.

  2. Removed the network parameter from the requestMessage input in ChallengeRequest.js (thanks @YosephKS)
    I left the network parameter in the verify input in ChallengeRequest.js even though I don’t think this is required here anymore, it didn’t cause an issue.

  3. Set EXPIRATION_TIME in ChallengeRequest.js to resolve an error reported by ChallengeVerify:
    MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Bad Request(400): Message expired at RequestController.makeError

Happy to see an active community here prepared to help a newbie to Web3 development.

Now I will work on better understanding the Unity code behind the tutorial so I can integrate Web3 auth into my own simple WebGL Unity game.

I’m planning on starting here as it looks like the Moralis tutorial has used this WalletConnect/WalletConnectUnity: This project is an extension of WalletConnectSharp that brings WalletConnect to Unity. (github.com)

It is not clear to me in the Moralis WalletConnect prefab where I set my own WalletConnect ProjectID.

1 Like

It works now!
Thanks!

1 Like

Hey happy to hear that @SupDog :grinning_face_with_smiling_eyes:

For the Moralis WalletConnect prefab, can you let me know which are you referring to specifically? :thinking:

In the Unity project Azure PlayFab (NodeJS) with Unity | Moralis Web3 Documentation there is a WalletConnect object – a child of the AuthenticationKit\3rdParty\ objects.

Here you can set the WalletConnect properties under App Data – but there is no place to set the WalletConnect ProjectID. I’m making an assumption that I do need to set the ProjectID after reading this tutorial: How to Authenticate Users with WalletConnect | Moralis Web3 Documentation

I have found this which I will look at next: MoralisWeb3/unity-web3-game-kit: Unity Web3 Game Kit is the fastest way to connect and build games for Web3. It provides a single workflow for building high performance dapps. Fully compatible with your favourite platform. (github.com)

I was trying to understand how the ‘Azure PlayFab (NodeJS) with Unity’ Unity project was put together – I’m guessing it has used a subset of the unity-web3-game-kit, as there is an empty folder under assets named ‘Moralis Web3 Unity SDK’.

As I am planning to use Moralis in a WebGL Unity project I have tried adding the WebGL pre-compiler directive #define UNITY_WEBGL to AuthenticationKit.cs and MoralisWeb3AuthService.cs in the ‘Azure PlayFab (NodeJS) with Unity’ project, but that just results in errors due to a missing namespace Web3GL, adding the necessary using directives using Moralis.WebGL results in a namespace not found message, adding the Moralis web3-unity-sdk package to the project results in GUID conflicts.

I feel I’m getting close though :blush: