Showing results for 
Search instead for 
Did you mean: 

WebSocket doesn't open

Level 3

I am currently working on the development of an app under Unity 2019.3.8.f1. Device target is Oculus Quest 1 & 2 (focus on 1 for the moment). Script are developed in C# 4.0.
My problem is : to exchange data, I want to open a websocket. The code (see below) works if I launch my app under Unity, but doesn't when launched in my Quest.

        public async Task<bool> Open()
            Application.Model.DebugLogManager.WriteLogs("Attempt to open socket");
            await OpenWebSocket();
            return true;
        private async Task<bool> OpenWebSocket()
            ws = new ClientWebSocket();
            Uri serverUri = new Uri("ws://X.Y.Z.W/mywebsocket");
            await ws.ConnectAsync(serverUri, source.Token);
            return true;

I added some traces before and after the ws.ConnectAsync. The one before is well written ; the one after is not.

Moreover on my server side, I don't receive any query, so I guess that it is not sent or something.

I tested the following tricks to get more information:

  • In Build Setting, "Internet Access" is set to Mandatory
  • Checked the value of internetReachability that sends back ReachableViaLocalAreaNetwork (I read the documentation, I know it doesn't prove anything, but still)
  • With Www class I tested to reach an external website, and it works.
So... who's my savior ?

[EDIT] I just tested to call a REST API and same issue : the connection is never achieved. Good news or bad news : the origin of the issue might be the same.