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.