Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • Feature Requests /
avatar image

ezentertainmentstudio suggested an idea · Aug 22, 2016 at 03:38 PM · Authentication

PlayFab Login Timeout

Hi All,

We are using PlayFab integration for our Unity3D game. We have recently run into some unpleasant issues when attempting to have a user login to PlayFab (LoginWithAndroidDeviceIDRequest and/or LoginWithEmailAddressRequest) while having a poor internet connection.

Using step-by-step debugging we traced the issue to the PlayFabWWW class - Post coroutine.

The issue here is that the coroutine yields and waits for the WWW to complete. This leads to a timeout of 30 seconds or more which is unacceptable for users. Since Unity does not allow the WWW timeout to be changed, we did a bit of a hack inside the PlayFab coroutine:

private IEnumerator Post(WWW www, Action<string> wwwSuccessCallback, Action<string> wwwErrorCallback)
{
DateTime coroutineStart = DateTime.Now;
bool timeoutReached = false;
while(!timeoutReached && !www.isDone)
{
yield return null;
if((DateTime.Now - coroutineStart).Seconds >= 5)
{
timeoutReached = true;
}
}
if(timeoutReached)
{
www.Dispose();
wwwErrorCallback("Request timed out.");
yield break;
}
//... Rest of the code here ...
}

Using this method we reduced the timeout to a reasonable value.

We would like to know:

1. Do you think the above hack might cause issues? Our testing did not reveal any, but we don't really know all the use-cases for the Post coroutine.

2. Would it be possible, in the future, for PlayFab SDK to use for the WWW Post the timeout value from PlayFabSettings.RequestTimeout (or another setting)?

Thank you and Best Regards,

Alex

EZ ENTERTAINMENT

thub.nodes.view.add-new-comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 comments

· Add your reply
avatar image

Brendan commented · Aug 22, 2016 at 08:07 PM

I take it you're referencing this thread? http://answers.unity3d.com/questions/566671/any-way-around-www-timeout-on-android.html

In general, it should be relatively safe to have a shorter timeout for Login calls, as the majority of the time any of those requests take more than 5 seconds to return, you're looking at a failure case. However, that's not long enough for all calls in the service, technically. In specific, the ExecuteCloudScript call may take slightly more than 5 seconds to return, since the maximum runtime on a Cloud Script is itself 5 seconds. So I'd have to recommend setting your generalized timeout higher, and doing thorough testing to ensure that you've checked all your use cases.

thub.nodes.view.add-new-comment
ezentertainmentstudio

People who like this

1 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

ezentertainmentstudio commented · Aug 23, 2016 at 03:27 PM

Hello Brendan,

Thank you kindly for your reply.

Indeed, the question is related to the thread you mentioned, although our particular problem came strictly from how long it takes to authenticate the user to PlayFab, regardless of platform - because, in our case, the game initialization is halted waiting for the login to either succeed or fail.

We will go with a timeout of 10 seconds, then, just in case and perform some more testing.

Still, if possible, it may prove useful in the future to allow a finer control of various timeouts using PlayFabSettings class.

Best Regards,

Alex

EZ ENTERTAINMENT

thub.nodes.view.add-new-comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Brendan commented · Aug 23, 2016 at 08:01 PM

Actually, if you use WebRequest instead, we do have a timeout defined in PlayFabSettings - would that be an option for you?

thub.nodes.view.add-new-comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

ezentertainmentstudio commented · Aug 24, 2016 at 08:52 PM

Hello Brendan,

Yes, that would certainly be a valid option. However, I have found no way to specify which option the Login methods should use (Post or WebRequest). Is it possible to select this?

Thank you,

Alex

EZ ENTERTAINMENT

thub.nodes.view.add-new-comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Brendan commented · Aug 24, 2016 at 09:02 PM

For non-Windows Phone (WSA and WP8) platforms, you can set your WebRequestType to HttpWebRequest in your PlayFabSettings. That will cause the Unity SDK to use WebRequest, rather than WWW. But to be clear, the request uses the "post" method in either case.

thub.nodes.view.add-new-comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

ezentertainmentstudio commented · Aug 25, 2016 at 02:54 PM

Sorry, when I wrote "post" I meant "WWW Post". I think we will stick with our little hack, for now, as testing suggests that using WWW it is faster than HttpWebRequest.

Thank you very much for your support!

Best Regards,

Alex

thub.nodes.view.add-new-comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Your Opinion Counts

    We would love to know what you need. Submit your ideas and upvote others to help us prioritize.

    Sign in to post a new idea

    Follow

    Follow This Idea

    1 Person is following this .

    avatar image

    Related Ideas

    Provide secure GameCenter login

    Epic Games and GOG Galaxy Accounts

    Ability to link server custom id to an existing account

    2FA Security

    Epic Games Store (EGS) authentication

    API Logout call for security

    Vote 2-layer Security And Sercet Key

    Blocking specific countries

    Authentication management for Azure AD B2C tenant

    Get PlayFab IDs from Nintendo Service Accounts

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges