Hi guys!
I looked at several projects(created by Unity Tech), but I still did not understand how to connect some Match in WebGL. My steps:
useWebSockets = true
build for WebGL
Run in editor and browser
LAN Host in redactor and LAN client in browser. Its work
What I want:
1.Create match(in Editor or any possible Platform. I know that you cant lan host in WebGL, only connect)
2.Find match in browser
3.Connect
link to NetworkLobby Example from Unity tech(its like Tanks Example)
Someone can tell me how I can do it? (find and connect to internet match from WebGL).
Thanks in advance!
Their match maker doesn’t work with WebGL game. If you host a server in editor and tick the use websocket in network manager or set it true in NetworkServer and open the client in Firefox then it should work, On Edge and chrome you should use build and run for it to be hosted in a local web server to work.
Maybe I dont understand well. For example, I build WebGL project and run it on Firefox on my friend’s PC. I run server in Editor (LAN Host) on my PC. Then my friend try connect to server(using my IP), but nothing happens. When I try do the same at the same PC, its work nicely.
Briefly : computer1-computer1 = work nicely, but
computer1-computer2 = cant find/connect to match
How my friends can connect(WebGL) to my macth(Server in editor) ?
Aha , This is due to security issues.
You need a cross domain reference policy file which allows the connection to happen I guess. check the webGL part of the manual in relation to multiplayer.
Actually I was wrong, cross origin resource sharing seems to only apply to HTTP requests.
See the manual page related to it
In the coming days I should make this workin so can update you, if I forgot, send me a private message. I’m working on a cross mobile and WebGL multiplayer product so I have to make this work today or tomorrow and it should work.
Any solution?
Just give me idea how I can connect to non-localhost ip address this thing. >_<
Browser : Chrome and Firefox
Host : github.io
Unity: 2017.2.0b5
@Danila24ru Your error is different to the error mentioned in the rest of the thread. The connection string you use in your unity scene should begin with “wss://” which indicates that you are trying to connect with SSL/HTTPS secured connection.
As for connecting to a non-local IP address/host, the problem you are encountering is related to CORS support, which is a built-in security functionality of most browsers. There are a couple of ways you can get around this:
You could start Chrome in insecure mode. This answer shows how to start in insecure mode.
You’ll need to update the server code to allow requests to come through from custom domains. or you can use third party servers that allow custom domains.