2019.2.11f1: UnityWebRequest GET not working on HoloLens but System.Net.WebRequest does

I set up a minimal Unity project with only one empty GameObject and the following script attached:

using System.Net;
using UnityEngine;
using UnityEngine.Networking;

public class WebRequest : MonoBehaviour
{
    // Start is called before the first frame update
    public string serverUrl;  // some.local.network.ip:port
    void Start()
    {
        Debug.Log("Sending request to" + serverUrl);
        UnityWebRequest getRequest = new UnityWebRequest(serverUrl, UnityWebRequest.kHttpVerbGET);
        getRequest.chunkedTransfer = false;
        getRequest.SendWebRequest();
    }
}

I tested the code above with a local NodeJS server and successfully received requests when running a) the code in the (local) Editor and b) a built exported to a Android device and c) a built app in the HoloLens (1) emulator. When exporting the same code to a UWP application with Windows Mixed Reality enabled, the request is not received. I enabled EnterpriseAuthentication, InternetClient, InternetClientServer, PrivateNetworkClientServer, WebCam, Microphone and SpatialPerception. I however receive some proxy errors:


Curl error 7: Failed to connect to proxy.<url>.net port 1080: Connection refused```

I assume that the institute network is some influential factor here. However, the Android request worked anyway and also replacing the `UnityWebRequest` with:

```csharp
    System.Net.WebRequest request = System.Net.WebRequest.Create(serverUrl);
    request.Credentials = CredentialCache.DefaultCredentials;
    WebResponse response = request.GetResponse();

allows the HoloLens application to reach the remote NodeJS server. I found related issues here and here but unfortunately neither updating Unity nor using trailing backslashes or chunkedTransfer solved it for me.

Tested Unity Version: 2019.2.11f1 and 2019.2.10f1
HoloLens Version: 17763.806.x86fre.rs5_release_svc_prod1.191005-1655

Any suggestion about how to get UnityWebRequest working on HoloLens in a network with an HTTP proxy would be much appreciated.

I don’t think this is particular to HoloLens or XR. You might be better served posting on the Windows forum: Unity Engine - Unity Discussions

Hello joejo,

I just created an AppX package to test it on a different Windows machine and you are right. It does not work either. When I disable “Automatically detect settings” in the ‘Proxy’ section of Windows ‘Settings’ the request reaches the server. In both cases (HoloLens/PC), browsers such as Edge and/or Firefox where able to reach the server even with enabled automatically detected proxy settings.

I posted the updated question in the Windows forum:

I disabled “Automatically detect settings.” It still doesn’t work. Do you have any idea what else it might be? I’ve noticed it does work in a development run from Visual Studio, but it doesn’t when I build it as a package from the master version.