Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

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.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. 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. And always feel free to hit us up on Twitter @MxdRealityDev.

cannot receive HTTP messages on HoloLens server

i've been trying for days to implement a simple server on HoloLens to receive HTTP packets sent from a smart object on a local network.

My code so far is the following (i report only the part of the code that actually runs on HoloLens):`

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.Networking;
using System.Net.Sockets;
using System.Net;
using System.Threading;
using System.Text;
using UnityEngine.UI;

#if !UNITY_EDITOR
    using Windows.Networking;
    using Windows.Networking.Sockets;
    using Windows.Storage.Streams;
    using Windows.Networking.Connectivity;
#endif

public class DolphinManager : MonoBehaviour
{
    private static string holoLensIpAddr = "192.168.0.147";  
    private static int holoLensPort = 12345;

#if UNITY_EDITOR
    private HttpListener _listener;
#endif

#if !UNITY_EDITOR
    private StreamReader reader;
    private StreamSocketListener listener;
#endif

    void Start()
    {    

#if UNITY_EDITOR
        Invoke("InitializeUnityServer", 4f);

#else
        Invoke("InitializeUWPServer", 4f);
#endif
    }

#if !UNITY_EDITOR
    private async void InitializeUWPServer()
    {
            try
            {
                listener = new StreamSocketListener();
                serverHost = new Windows.Networking.HostName(anyIp);
                listener.ConnectionReceived += Listener_ConnectionReceived;
                listener.Control.KeepAlive = false;
                await listener.BindServiceNameAsync(holoLensPort.ToString());

            } catch(Exception e) { Debug.Log(e.Message); }

    }
#endif


#if !UNITY_EDITOR
    private async void Listener_ConnectionReceived(StreamSocketListener sender, StreamSocketListenerConnectionReceivedEventArgs args)
        {
            Debug.log("message received!");
        }

The server starts correctly, but when i try to send a packet from my smart object, Listener_ConnectionReceived() is not triggered.

I have already set the PrivateNetworkClientServer capability on the app manifest.

What could be wrong? Thank you in advance!

Sign In or Register to comment.