- Home /
Webgl - Networked game - process of uploading - errors - questions
Hi I am making a multiplayer game with unity and have a couple of doubts.
First
the game consists of a bunch of clients, that connect to a single dedicated master Client (also a unity game on its own: hereafter referred to simply as 'server'). All of these clients speak to each other by relaying their information through this server using the LLAPI. I have made the game, which thus far is just a little man, some camera work and a chat system, work in webgl while speaking locally to my server.
I have now tested uploading it to Itch.io which works locally, as in speaking to '127.0.0.1'. However it does not work in firefox or edge. as it gets the following errors:
"exception thrown: SecurityError: The operation is insecure.,_JS_UNETWebSockets_SocketCreate@blob:https://v6p9d9t4.ssl.hwcdn.net/019f3d09-29d8-45d6-9b26-e85868c74456:2:234689" - unityLoader.js
its as soon as this code is run the error comes
Debug.Log("connecting...");
// does player have a name?
string pName = GameObject.Find("NameInput").GetComponent<InputField>().text;
if (pName == "")
{
Debug.Log("Enter a name");
return;
}
playerName = pName;
NetworkTransport.Init();
ConnectionConfig cc = new ConnectionConfig();
reliableChannel = cc.AddChannel(QosType.Reliable);
unReliableChannel = cc.AddChannel(QosType.Unreliable);
HostTopology topo = new HostTopology(cc, MAX_CONNECTION);
hostId = NetworkTransport.AddHost(topo, 0);
connectionId = NetworkTransport.Connect(hostId, "127.0.0.1", port, 0, out error);
connectionTime = Time.time;
isConnected = true;
NetworkServer.useWebSockets = true;
Debug.Log("connected");
Secondly
I would like to ask how it is I would go about uploading the entire game to the internet. as Far as I can understand I could upload the server to a host and then guide the clients to that URL and that should work? So could I for example upload the server to AWS and then just have my clients connect to it from any browser? has anyone tried doing this? I love to hear what sort of solution people use for this.
e.g:
connectionId = NetworkTransport.Connect(hostId, "URL_pointing_to_the_server", port, 0, out error);
Still getting the same exception thrown: SecurityError:
$$anonymous$$ im getting to understand that this happen because I cannot create a secure websocket in a browser and for some reason chrome allows this between browser and local connection "127.0.0.1" where firefox doesnt even allow that.
Im wondering how to make a secure websocket connection:
there is some information in this thread but I have tried this:
https://forum.unity3d.com/threads/unet-wss-https.440463/
to no avail.