Search Unity

unity and websocketsharp

Discussion in 'Multiplayer' started by Yeowza, Dec 6, 2021.

  1. Yeowza

    Yeowza

    Joined:
    May 9, 2014
    Posts:
    48
    Hey guys I'm making a unity webGL build with websocketsharp, https://github.com/sta/websocket-sharp

    Weird thing is it works fine when I run it from client, I can send and receive messages with nodeJS but when I upload the build to my server I get this error when I try to connect to the server

    12/5/2021 6:53:40 PM|Fatal|.|System.Net.Sockets.SocketException (0x80004005): Could not resolve host 'mydomain.io'
    Desktop.loader.js:1 at System.Net.Dns.Error_11001 (System.String hostName) [0x00000] in <00000000000000000000000000000000>:0

    here is how I am connecting in C#

    ws = new WebSocket("wss://mydomain.io:8000");
    ws.SetProxy("https://mydomain.io/server", "", "");

    I have no idea how to debug this. Why would it work in the unity editor but not when I upload to the server? Is websocketssharp the best way to communicate with a nodeJS server?
     
    mimiCryMuffin likes this.
  2. Yeowza

    Yeowza

    Joined:
    May 9, 2014
    Posts:
    48
  3. Ryuuguu

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    391
    NativeWebSocket is gnu general public license v3.0 or later so if you use it all your code is legally GPL3 and you must make your source code freely available. I"m sticking with websocket-sharp
     
    MrBigly likes this.
  4. daniel414

    daniel414

    Joined:
    May 13, 2020
    Posts:
    14
    @Ryuuguu Where did you see that license?
    The Repo of NativeWebSocket linked above clearly says that it is licensed under the Apache License v2 which, to my understanding, does not force you to make your source code public.
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Yes, the readme says it's Apache 2.0 and you don't have to open your code as well.

    The name is misleading though. It is using the C# API System.Net.WebSockets, not native (non managed) APIs. The WebSockets in .Net Standard 2.0 don't support proxies afaik, which WebSocket Sharp does.