Search Unity

POST request takes about 2 minutes to complete in WebGL

Discussion in 'Web' started by stryker_x, Feb 15, 2019.

  1. stryker_x

    stryker_x

    Joined:
    Aug 1, 2014
    Posts:
    1
    I have an app that communicates with an external server I have set up. It does GET and POSTS. The GET requests are quick, but the POST requests take about 2 minutes. It works just fine when I build it for desktop or if I'm just testing it from inside unity. Its only when I build it for WebGL. I'm not getting any errors when I look at it through a dev build, it just hangs for around 2 minutes, then finishes.

    Here's my POST code (pretty basic)

    Code (CSharp):
    1.     public IEnumerator postAction(string action)
    2.     {
    3.         WWWForm form = new WWWForm();
    4.         form.AddField("actionName", action);
    5.         using (UnityWebRequest www = UnityWebRequest.Post("http:/webaddress.example/callAction", form))
    6.         {
    7.             yield return www.SendWebRequest();
    8.  
    9.             if (www.isNetworkError || www.isHttpError)
    10.             {
    11.                 Debug.Log(www.error);
    12.             }
    13.             else
    14.             {
    15.                 Debug.Log("Form upload complete!");
    16.             }
    17.         }
    18.     }
    Code (CSharp):
    1.     public void enterPassword()
    2.     {
    3.         if (inputField.text.ToLower() == password.ToLower())
    4.         {
    5.             accessGranted.SetActive(true);
    6.             StartCoroutine(masterScript.postAction("perp"));
    7.         }