Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

unity and websocketsharp

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

  1. Yeowza

    Yeowza

    Joined:
    May 9, 2014
    Posts:
    36
    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?
     
  2. Yeowza

    Yeowza

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

    Ryuuguu

    Joined:
    Apr 14, 2007
    Posts:
    381
    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:
    10
    @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:
    2,945
    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.