Unity Networking and WebGL

How do I create a server in WebGL? When I start up the WebGL version of the game, I get this:
3578437--289119--upload_2018-7-27_16-34-48.png
Is WebGL networking even possible?

Enable “Use WebSockets” in Network Manager.

1 Like

It still doesn’t let me create a server or use match maker.

WebGL version cannot be server.
Run one Windows instance as server. Then WebGL-instance can connect to server as client.

1 Like

Thanks mate! I got it to work. :smile:

i dont understand what you mean Yuri

WebGL cannot act as a server. Use a Windows or other standalone platform build as the server. By default Unet on all platforms other than WebGL will use UDP for Unet’s network transport, but WebGL is not capable of using UDP, only Websockets. So you tell the standalone build to use Websockets instead of UDP so WebGL clients can talk to it.

https://docs.unity3d.com/ScriptReference/Networking.NetworkManager-useWebSockets.html

2 Likes

kindly tell me how to set multiplayer using WebGL ?? i upload webGL build on Domain(Server) and try to play multiplayer game by running two instances on different laptops but it didnt work for me both players cant find each other. Kindly help

You don’t mention a game server they’re connecting to…do you have one? Are they both able to connect to it?

1 Like

i upload the build file on server and both players open the file but they cant find each other please help me

There isn’t any magic - you still need a game server hosted somewhere for both players to connect to. It sounds like you’ve created a single player game with no networking and no game server.

I mention the server IPaddress in Network Manager Still it didnt make connection between two clients

If u help me it will be very honourable for me

You need a SERVER

You will not be able to “make connection between two clients”. You need a standalone build (not WebGL, instead Windows/Linux/Mac, etc) set up to act as a server which the two clients connect to. You will also need to make sure the server build is set to use websockets.

using PC/Windows/Linux it works well but i want to Make i webGL -_- it didnt work . Do u have any idea ??

nd i want to upload my game on domain(server) and make two clients to connect with each other. Any idea how to do ??

am getting this issue on executing webgl html page "Uncaught TypeError: Cannot read property ‘id’ of null "
plz help me to solve this

WebGL uses websockets, you’d have to configure your standalone server build to use websockets instead of UDP in order for the WebGL build to be able to connect to it.

Clients don’t connect to each other, period. Not sure if you’re meaning something different, or don’t understand how it works, but the clients in order to affect each other will do so through their connection to the same server.

Wanted to add to this thread that the aforementioned websocket process worked for me, but I had to use Firefox instead of Edge in order for it to work. I’m using 2019.3.0a7, and auto graphics api which when I turn off goes to WebGL 2.0… I believe this means that it also won’t work with IE and I am using Chrome 75 which also didn’t work.