WebGL www Unknown Error

public void Start()
{
StartCoroutine(LoginIeumerator());
}
private IEnumerator LoginIeumerator()
{
string url = “xxxxx.com”;
print(url);
using (UnityWebRequest www = UnityWebRequest.Get(url))
{
yield return www.SendWebRequest();
if (www.error == null)
{

                // SceneManager.LoadSceneAsync(1);
                print("OK");
                //}
            }
            else
            {
                
                print("No");
            }
        }
    }

I am running in the editor without exceptions, but when I package it, Unknown Error appears. What is the reason? I am using the version: 2018.2.3f1

Error may not be null but may be empty. Are you sure you are checking this too?

This is how I deal with www without problems :

float timer = 0;

        while (!wwwOperation.isDone && timer < 50)
        {
            timer += Time.deltaTime;
            yield return null;
        }

        if (string.IsNullOrEmpty(wwwOperation.error) && timer <= 50)
        {

I had the same error, while the game worked fine in the editor, and in windows build, but I had an “Unknown error” on my HTML5 build.
This thread helped me understood the issue, even if my error was a bit different: https://forum.unity.com/threads/unknown-error.425412/

It seems like it is a security error, the website is not recognized as local/safe. In my case, I had put the address of the website hosting the html5 and my PHP files as https, when it was actually http only (yes, I know I have to solve this :wink: ). Changing the website address to http worked fine.

Hope it helps someone else later :wink: