WWW not working in UWP, but it works for iOS and Android

Hi
I cannot get my app to communicate with my web server when exported for UWP. But it works for iOS and Android.
The codes are below and I have enabled client capability in the app setting page.
Thank you for your help!

void start()
   {
        string url = "http://www.somedomain.com";
        WWW www = new WWW(url);
        StartCoroutine(WaitForRequest(www));

    }



    IEnumerator WaitForRequest(WWW www)
    {
        yield return www;

        // check for errors
        if (www.error == null)
        {
            Debug.Log("WWW Ok!: " + www.text);
        }
        else
        {
            Debug.Log("WWW Error: " + www.error);
        }
    }

The result is:
WWW Error: Cannot connect to destination host

Did you adjust the capabilities in the “Package.appxmanifest” file? Here is how to access the Capabilities I’m referring to…

  • Build UWP Player via Unity

  • Open generated .sln file in Visual Studio

  • Open file “Package.appxmanifest”

  • Switch to “Capabilities” tab in “Package.appxmanifest”

  • Enable whatever Capabilities you need, e.g.: Internet (Client & Server), Internet (Client), Point of Service, Private Networks (Client & Server), Remove System, etc

  • Press in Mainmenu > Build > Build Solution

If you post source code, I recommend to use code-tags, makes it easier for people to read:

1 Like

Many thanks to Peter77. All the options enumerated above are enabled. But still not working.

That’s weird. Are you using some public URL to connect to?
Have you done a clean build with internet capabilities enabled in the manifest?

Peter77 and Aurimas-Cernius
Thank you very much. I have at last found out the reason which turns out be the fact that the failure is not because of Unity, but of my web host (webhxxxxxx) who has blocked my ip address. It now works fine as nice as iOS/Android. Thank you for your help which has led me to find out the real reason.

1 Like