简体   繁体   中英

CAn't connect to a local server (XAMPP) from HoloLens

I'm trying to build a connection between the HoloLens and XAMMP server. when i test the app on unity, it works fine but it doesn't work on the device.

Ps: you can access the server when writing the IP address of the server In Microsoft Edge.

  • Windows defender firewall is disabled
  • Network capabilities are checked (publishing settings)
  • XAMPP server is reconfigured to be accessible to all devices

what am I missing here ? how can I make this work ?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class test : MonoBehaviour
{
    public Text playerDisplay;
    public Text score;
    public Button submit;
    public InputField nameField;
    public GameObject bb;
    public Text Error;

    public void CallLogIn()
    {
        StartCoroutine(Loginplayer());
    }

    IEnumerator Loginplayer()
    {
        WWWForm form = new WWWForm();
        form.AddField("name", nameField.text);


        WWW www = new WWW("http://192.168.1.100/sqlconnect/test.php", form);
        yield return www;
        if (www.text[0] == '0')
        {

            DBManager.username = nameField.text;
            DBManager.score = int.Parse(www.text.Split('\t')[1]);

            playerDisplay.text = "player: " + DBManager.username;
            score.text = "score: " + DBManager.score;

            bb.SetActive(true);
        }
        else
        {
            Error.text = "save failes. Error #" + www.error;
            bb.SetActive(false);
        }
        DBManager.logedOut();


    }
}

I encountered this kind of issue as well. I tried to connect the HoloLens to different entities (MySQL DB, OPCUA Server) but it always fails on the HoloLens (working fine in the editor). Searching on google only revealed similar problems from other people, but no solutions.

So my solution is to use the WWW class to receive data from a HTML-Webserver that hosts plain text. This server (I used nodejs and python) executes the query to the database depending on the GET-request it receives from the HoloLens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM