Search Unity

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

Discussion in 'VR' started by avikom, Nov 11, 2019.

  1. avikom

    avikom

    Joined:
    Jun 18, 2019
    Posts:
    7
    I set up a minimal Unity project with only one empty GameObject and the following script attached:

    Code (CSharp):
    1. using System.Net;
    2. using UnityEngine;
    3. using UnityEngine.Networking;
    4.  
    5. public class WebRequest : MonoBehaviour
    6. {
    7.     // Start is called before the first frame update
    8.     public string serverUrl;  // some.local.network.ip:port
    9.     void Start()
    10.     {
    11.         Debug.Log("Sending request to" + serverUrl);
    12.         UnityWebRequest getRequest = new UnityWebRequest(serverUrl, UnityWebRequest.kHttpVerbGET);
    13.         getRequest.chunkedTransfer = false;
    14.         getRequest.SendWebRequest();
    15.     }
    16. }
    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:

    (Filename: C:\buildslave\unity\build\Modules/UnityWebRequest/Implementations/TransportCurl.cpp Line: 734)

    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:

    Code (CSharp):
    1.     System.Net.WebRequest request = System.Net.WebRequest.Create(serverUrl);
    2.     request.Credentials = CredentialCache.DefaultCredentials;
    3.     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.
     
    Last edited: Nov 11, 2019
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
  3. avikom

    avikom

    Joined:
    Jun 18, 2019
    Posts:
    7
    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.
     
  4. avikom

    avikom

    Joined:
    Jun 18, 2019
    Posts:
    7
  5. joseGuate97

    joseGuate97

    Joined:
    Mar 1, 2018
    Posts:
    57
    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.