question

Richard McKinney avatar image
Richard McKinney asked

Request Timeout ignored in Unity sdk?

I wanted to update my login timeout, since on a bad connection we're often sitting around waiting for a long time. Just had a look at the code in PlayFabUnityHttp and there are no usages of PlayFabSettings.RequestTimeout. It looks like it's only referenced when using HttpWebRequest. If I update the initialization to set the timeout, it seems to work as expected. Any reason I shouldn't do this?

var www = new UnityWebRequest(reqContainer.FullUrl)
{
    uploadHandler = new UploadHandlerRaw(reqContainer.Payload),
    downloadHandler = new DownloadHandlerBuffer(),
    method = "POST",
    timeout = PlayFabSettings.RequestTimeout
};
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.

Ozan Yilmaz avatar image Ozan Yilmaz commented ·

I wonder the answer. Sometimes, my game stucks on loading screen due to this

0 Likes 0 ·
Ozan Yilmaz avatar image Ozan Yilmaz commented ·

Any update about this?

0 Likes 0 ·
franklinchen avatar image
franklinchen answered

Hi @Stefan Velnita, we got the confirmation from SDK team. This is by design.

The PlayFabSettings.RequestTimeout is only meant to be hooked up to our HttpRequest class - PlayFabWebRequest object. If you wish to use the RequestTimeout, please switch their PlayFabSettings.RequestType to WebRequestType.HttpWebRequest which does obey the PlayFabSettings.RequestTimeout.

1 comment
10 |1200

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

Richard McKinney avatar image Richard McKinney commented ·

But that just changes this issue to "There's no support for timeouts when using UnityWebRequest, which leads to very bad experiences on poor internet connections." I've been just been patching over it after updating our sdk and it seems to work fine. Is the intention really that, for some reason, timeouts are only supported when using HttpWebRequest?

1 Like 1 ·
Sarah Zhang avatar image
Sarah Zhang answered

[Edited] This is by design. The PlayFabSettings.RequestTimeout is only meant to be hooked up to our HttpRequest class - PlayFabWebRequest object. If you wish to use the RequestTimeout, please switch their PlayFabSettings.RequestType to WebRequestType.HttpWebRequest which does obey the PlayFabSettings.RequestTimeout.

1 comment
10 |1200

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

Stefan Velnita avatar image Stefan Velnita commented ·

Hi! Any update about this?

0 Likes 0 ·
giorgiotino avatar image
giorgiotino answered

I have stumbled upon this problem as well, and I don't really see why a timeout cannot be set for the UnityWebRequest. Besides the fact that PlayFabSettings.RequestTimeout is in ms while UnityWebRequest is in s, seems to work fine if I just set the timeout value of each UnityWebRequest.

I would love to use the UnityWebRequest for a bunch of reasons:

- It uses coroutines and not threads. HttpWebRequest system currently has an issue that I have reported here: https://github.com/PlayFab/UnitySDK/issues/234

- We have a bunch of Unity Editor scripts that rely on Admin calls, and for some reasons they do not really work (http requests are NEVER sent, I guess there's a problem with the queue, probably the worker thread is not setup correctly in the unity editor?). I have to manually switch to UnityWebRequest whenever I need to call any of those Admin APIs within the Editor, and this is annoying.
- HttpWebRequest sets the Proxy value to null, thus making it impossible to debug through e.g. Charles.

I'd love to al least understand what's the technical reason for those missing pieces in both RequestTypes, because I don't really want to modify playfab code if I am missing something important...

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.