- Home /
Unity LLAPI HTTPS webSoket ->WSS
Hello. I am developing a game for WebGL (social network). They are using HTTPS only. For the network I use LLAPI (since HLAPI does not support WebGL). When I tested it on HTTP, it worked. However, when I loaded the game and went through HTTPS, the buttons "start client" got the error: Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
if ( GUI.Button( new Rect(10, 70, 250, 30), "start server" ) )
{
_isStarted = true;
_isServer = true;
NetworkTransport.Init();
HostTopology topology = new HostTopology(m_Config, 2);
m_WebSocketHostId = NetworkTransport.AddWebsocketHost(topology, port, null); //add 2 host one for udp another for websocket, as websocket works via tcp we can do this
m_GenericHostId = NetworkTransport.AddHost(topology, port, null);
Debug.LogError(topology.MessagePoolSizeGrowthFactor+";"+ topology.ReceivedMessagePoolSize+";"+ topology.SentMessagePoolSize+";"+m_Config.FragmentSize+";"+m_Config.MaxCombinedReliableMessageCount+";"+m_Config.MaxCombinedReliableMessageSize+";"+m_Config.MaxSentMessageQueueSize+";"+m_Config.WebSocketReceiveBufferMaxSize);
}
#endif
if (GUI.Button(new Rect(10, 100, 250, 30), "start client"))
{
_isStarted = true;
_isServer = false;
NetworkTransport.Init();
HostTopology topology = new HostTopology(m_Config, 2);
m_GenericHostId = NetworkTransport.AddHost(topology, 0); //any port for udp client, for websocket second parameter is ignored, as webgl based game can be client only
byte error;
m_ConnectionId = NetworkTransport.Connect(m_GenericHostId, ip, port, 0, out error);
Debug.LogError(error + ";");
}
All that I have found, indicating that LLAPI can not use WSS. But HTTPS uses only WSS. Can you please tell me what to do? I do not want to change to another technology LLAPI after weeks of development
For the certificate, I use cloudflare
I do not use Unity matchmaking. The master server is written in LLAPI and is on my VDS. There is also a build (index.html).
string ip = " XXX.XXX.XXX.XX ";//VDS IP
P.S. Sorry for my English. It's not me. This google translate
Answer by Seth-Robinson · Mar 05, 2018 at 02:46 AM
At this time wss isn't supported natively by Unity.
However - It's possible to setup a utility such as stunnel under Linux to externally add this functionality transparently.
More info: https://www.codedojo.com/?p=2167 ( How to get your Unity LLAPI/WebSocket WebGL app to run under https with AutoSSL & stunnel )
Your answer
Follow this Question
Related Questions
Crossdomain.xml problem in HTTPS / SSL 0 Answers
WebException/TlsException during HTTPS Request 2 Answers
Is it possible to do ssl certificate pinning in Unity iOS 1 Answer
WWW/WWWForm, does Unity validate SSL certificates over HTTPS? 0 Answers
how do setup WebPlayer Installer on an https? Esp. Facebook. 0 Answers