Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

Unity: Send HTTPS request from hololens

Hi guys,
Using Unity, I am developing a Hololens app that sends HTTPS Get/Post requests to Google Drive.

Through Google Search, I know that UnityWebRequest is one of recommended solutions. And I have tried to use that UnityWebRequest. I am able to send HTTP Get Request successfully, but I am fail with HTTPS Get Request even though I check all permissions in the Unity's publish settings.

Could somebody please instruct me how to send HTTPS requests in Hololens?

Thanks!

Comments

  • Options

    UnityWebRequest should work fine. We currently use it.

    The trick is that with Unity 2017.3 and beyond there is a but with UnityWebRequest and UWP. It will return isNetworkError or isHttpError true every time even though there was no error.

    You will want to check your errors instead by looking at the Response code and response data to see if your message was successful.

    Taqtile

  • Options

    @mark_grossnickle said:
    UnityWebRequest should work fine. We currently use it.

    The trick is that with Unity 2017.3 and beyond there is a but with UnityWebRequest and UWP. It will return isNetworkError or isHttpError true every time even though there was no error.

    You will want to check your errors instead by looking at the Response code and response data to see if your message was successful.

    Dear mark_grossnickle,

    Thanks for your response. My current app works fine in Unity play mode. But when I deploys in the real Hololens, my problem is as follows:
    1. When I check some of the permissions (in the publish setting), the error is "ssl connection cannot be established"
    2. When I enable all permissions, there is no error; but the response is empty.

    Could you please show me your code. Following is my code:
    public class WebRequestTest : MonoBehaviour {
    public GameObject debug;

    // Use this for initialization
    void Start () {
        StartCoroutine(test());
    }
    
    IEnumerator test()
    {
        string url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vQzuL0ALy5-v5dLwODTEgw67jwRsNA3L-GT7kooaClPgByMBz3Kwl8mhFspxMM63VbCpLDD3KFNy1dT/pub?output=csv";
        UnityWebRequest uwr = UnityWebRequest.Get(url);
        yield return uwr.SendWebRequest();
        string text;
        if (uwr.isNetworkError)
        {
            Debug.Log("Error While Sending: " + uwr.error);
    
            debug.GetComponent<Text>().text = "Error: " + uwr.error;
        }
        text = uwr.downloadHandler.text;
        Debug.Log(text);
        debug.GetComponent<Text>().text = text;
    }
    

    }

  • Options
    mark_grossnicklemark_grossnickle ✭✭✭
    edited April 2018

    Not sure offhand what is wrong but it could be returning bytes instead of text?

    webRequest.downloadHandler.data

    Also what version of Unity are you using? And on the device you may want to check uwr.responseCode and uwr.error regardless of uwr.IsNetworkError. Just so you can see what is returning.

    Taqtile

  • Options

    Thank you very much for your info. Based on your suggestions, I tried today and the results were as follows:
    1. uwr.isNetworkError is false
    2. uwr.responseCode is 0
    3. uwr.error is still "ssl connection cannot be established"
    4. uwr.downloadHandler.data is empty too
    I really don't know why. It is so desperate. My Unity version is 2017.3.0f3. Do we have to setting something special in the Hololens?

  • Options

    I tried your exact code above and it works fine for me on the device. My best guess is that 2017.3.0f3 has errors in it.

    I am on 2017.3.1.p2.

    Taqtile

  • Options

    Thank you very much for your help. It should be the reason that I fail. The version of Holotoolkit may affect the result too.

    I will check all of these stuff and inform to you later. My colleague took the device to an exhibition thus I could not try now.

  • Options

    Unity is so buggy its crazy. So much time wasted chasing down things that break from version to version.

    Best of luck

    Taqtile

  • Options

    Dear mark_grossnickle,

    I am happy to inform that the "simple app" with HTTPS request now works perfectly. I guess the problem was because of the network. It was strange as at that time, I already thought about this and tried to connect the Hololens to my mobile hot spot rather than the company WIFI network and it failed too.

    Anyway, I remove the old WIFI settings, and reconnect my Hololens to the company network and it is OK now.

    Thank you very much for your help. I appreciate that.

    Best wishes!!!

  • Options

    Hello everyone,
    are there any updates on this topic?
    I am using Unity version 2018.3.0f2 and I have a similar problem with UnityWebRequest that I can't get solved right now.

    My setup:
    I want to release my application for the HoloLens and use UnityWebRequest to retrieve data from a database. In Unity there is no problem compiling and I can read the data as expected. But when I release the application in debug mode in Visual Studio for the HoloLens I get the following errors:
    (isNetworkError || isHttpError) = true
    error = Unknown Error
    Response Code = 0

    What I've been trying to do so far:
    chunkedTransfer = false
    (in Unity) Edit > Project Settings > Player Settings > Capabilities
    - Internet client,
    - Internet Client Server and
    - Private Network Client Server

    I have an internet connection with the HoloLens, because if I disconnect the device I get the error message "cannot resolve destination host".

    Any help in this area is very appreciated.

  • Options

    Are you deploying with IL2CPP? I haven't updated to 2018.3 yet so I am unsure of that specific version but HTTPS and UnityWebRequest does work in prior versions now. I think I have tried it successfully on 2018.2... at the very least I know 2018.1 works but that is a pain to back port with the prefab changes.

    Taqtile

  • Options

    No, I deploy with .NET.
    I have now downgraded my Unity version to 2018.1.0f2. Then I could reproduce the error message that says "cannot reslove destination host" and I noticed a strange behavior: in Unity an http request can be sent if no "/" is set after the url, but on the HoloLens it does not work without the slash. This allowed me to fix all bugs and I can release my app now.

    Thanks for your help!

Sign In or Register to comment.