Secure Websockets Not Working

I am creating a game where clients communicate via WebSocket with a central management server. I have developed a test using normal websockets to ensure the game works, and it does. I am now changing the server to be a secure websocket server instead of a normal one and everything has stopped working.

I am using WebSocket-Sharp, have tested on Unity 2017.1.1 and 2017.2 beta, am on the Stable .NET branch and am only targeting Standalone platforms.

Current test code, attached to an object in the first scene is

WebSocketSharp.WebSocket _ws;
void Start () {
            UnityEngine.Debug.Log("Opening connection...");
            _ws = new WebSocket("wss://echo.websocket.org");
            _ws.OnOpen += (sender, e) => {
                UnityEngine.Debug.Log("Connection opened!");
                _ws.Send("{\"type\":\"game\"}");
            };
            _ws.Connect();
}

Upon starting the game, the console prints Opening connection but never (left it overnight) prints Connection opened.

it is question for web team. If you want to use unet for web sockets, you will need to use unet AddHost command and You should configure your server too to allow wss connection, check ConnectionConfig, there are some parameters there related to certificates which you need to set

How would I go about asking them? This seemed like the best forum to do so in.

gimme a sec i will try to find somebody :slight_smile:

Sorry dude, I did make quick search and nobody is able to answer. It is 3rd part library, so it is a questionable will it work or not. I suppose that you have problem with ssl handshake… Sorry, again I cannot help you :frowning:

Well crap. Thanks for your help and I would recommend your team retake a look at your
Simple Web Sockets for Unity WebGL example project since it uses the same library.

1 Like

For those still finding this forum post while searching for solutions:
As of unity beta 2018.2, SSL with WebSocketSharp and ClientWebSocket (.Net 4.5+) works without problems.

Sure… unless you try to build an Android project. In that case WSS doesn’t work, with both WebSocketSharp and ClientWebSocket: https://fogbugz.unity3d.com/default.asp?1078831_hi7qp3md6e3pqm4n

Has there been any progress on this? I am having the same issue with android and secure web sockets. I see that a similar issue was marked resolved for iOs but the issue persists for android.

In this other bug report, they replied that the issue will be fixed soon: https://fogbugz.unity3d.com/default.asp?1082184_b1jgq2gplqp9fnja

I still get this issue in 2019.3. Will there ever be a fix?

Re-report it as bug in the latest version. Especially issues with ClientWebSocket.