[Solved] ClientWebSocket WSS issues

I’m posting this in hopes of bringing more light to the problem I’ve been having with web sockets in Unity 2018.1 beta

I’d mainly like to know if this is planned for being fixed any time soon, or if I’m gonna have to look for alternatives in terms of making my player connections secure.

Before I begin I’d like to point out that HTTPS requests to the same server already work, it’s just the websocket WSS scheme that doesn’t seem to be able to connect.

The error i’ve mostly been seeing while debugging is “1002” which is an “Protocol Error” message. I believe this is simply because it can’t perform the SSL handshake properly.

So I’ve got a project using .Net 4.6 where I’ve tried to connect with the .Net 4.5 ClientWebSocket to a secure scheme at:
wss://mydomain.com

This simply does not work in unity as of now.

If I use this test tool to connect to my domain it works fine:

If I use an entirely separate standalone console application made with .Net 4.6 it also works fine to connect to my domain using ClientWebSocket with WSS

Other implementations like WebSocketSharp also seem to not be working.

A lot of solutions mentioned around the forums have not worked as they seem to be outdated when it comes to websockets, things like “allowing all certificates” (which is also a security risk) also do not work.

From my standpoint it would seem like it’s just a matter of unity implementing the known certificate authorities for websockets as they have for HTTPS already.

I posted this as a bug about a month back:
https://fogbugz.unity3d.com/default.asp?1016393_vhg86kfmphme5hm0

Unfortunately, HTTPS won’t work with Unity 2018.1. We’ve fixed that in 2018.2 though. Can you try the latest 2018.2 beta with this same code?

2 Likes

Latest 2018.2 beta actually solved this issue for me, thanks for the help!

1 Like

Any way to close my bug report as well?
https://fogbugz.unity3d.com/default.asp?1016393_vhg86kfmphme5hm0

Yes, I’ll resolve it.

1 Like