The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Why is my WebGL game failing to connect?

2022-01-05 19:41:47 pw: 'photon' , no apostrophes

I'm a fairly new user of Photon, with a decent amount of Unity experience.

Ideally the game should allow a player to generate a code or take that code from a friend and use it to join their friend's room, whereupon the game level loads.

My WebGL build seems quite unreliable - most times that I or my friends test the project above, I've clicked on 'Join' without any feedback, let alone joining the game. However, on occasion, everything seems to work. =/

Using the ctrl-shift-j console on Chrome seems to just be a loop of Sending: and TCP << outputs, which I can't parse.

Uploaded 2022-01-05T19:35:58+00:00 7641050 bytes .zip includes a built version of the WebGL player and the two main scripts for the 'lobby' in Photon.

Any advice would be much appreciated, I'm really confused here. Happy to share my screen by Discord or whatever...!

EDIT: Adding a OnJoinRoomFailed means that on the occasions when I can't join, I get the error,

2022 05 Jan 1208.framework.js.gz:2 <color=red>OnJoinRoomFailed, returnCode: 32758, with message: Game does not exist


2022-01-07 21:03:42

Hi @Reverend_Speed,

Thank you for choosing Photon!

First of all, you don't need to join any lobby. Joining a lobby is needed only when you need the list of rooms in the lobby which you don't so I would skip joining a lobby.

Second thing: regarding "Game does not exist" error, you could make use of JoinOrCreateRoom to avoid 'race conditions' when a client tries to join a room by name (code) while the room was not created yet.

Or you can make sure that the room is created first then call JoinRoom.

Third thing: this not WebGL specific.

Fourth: in general clients need to be connected to the same AppVersion (AppId, AppVersion) and same Region (server). Read more out "Matchmaking Checklist".

2022-01-08 11:14:59

Thank you for responding, I really appreciate the help! Addressing your points,

  1. Gotcha, I have removed the JoinLobby stuff from my code! Anything to simplify is great! =D

  2. As far as I can tell, there shouldn't be race conditions in my code. The room is created immediately after generating the code, using the code as the name. Even if it's one person using the game master & client in two browser windows, they need to generate the room/code in one and manually type it into the other and click 'join'. It's perhaps possible that some kind of automated process could be developed to create a race condition here, but it seems unlikely.

However! I have implemented JoinOrCreateRoom instead of CreateRoom (which seems to force me to create a lobby through the non-optional parameter, 'typedLobby').

  1. Not WebGL specific! That's great news, thank you!

  2. I will be voraciously reading that Checklist after making this post, much obliged!

I will say that in the days since I wrote the original post, I was alerted to the potential issue with Region for my game (as I'd like players in Aus to able to play with players in EU, for example). Reading your guide to dealing with this problem, I chose to solve it by passing the Master region to the Client through the generated code.

However, this solution requires the client to Disconnect, reconnect to the new region and then proceed to the established room. Unfortunately, this is resulting in a new error, as follows:

Got a unexpected Disconnect in LoadBalancingClient State: ConnectingToNameServer. Server: NameServer Trace:  at Photon.Realtime.LoadBalancingClient.OnStatusChanged (ExitGames.Client.Photon.StatusCode statusCode) [0x0046f] in G:\Unity\crackertest02\Assets\Photon\PhotonRealtime\Code\LoadBalancingClient.cs:3092

at ExitGames.Client.Photon.PeerBase+<>c__DisplayClass109_0.b__0 () [0x00001] in D:\Dev\Work\photon-dotnet-sdk\PhotonDotNet\PeerBase.cs:1181

at ExitGames.Client.Photon.TPeer.DispatchIncomingCommands () [0x00097] in D:\Dev\Work\photon-dotnet-sdk\PhotonDotNet\TPeer.cs:237

at ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () [0x00038] in D:\Dev\Work\photon-dotnet-sdk\PhotonDotNet\PhotonPeer.cs:1771

at Photon.Pun.PhotonHandler.Dispatch () [0x00030] in G:\Unity\crackertest02\Assets\Photon\PhotonUnityNetworking\Code\PhotonHandler.cs:222

at Photon.Pun.PhotonHandler.FixedUpdate () [0x00012] in G:\Unity\crackertest02\Assets\Photon\PhotonUnityNetworking\Code\PhotonHandler.cs:145

UnityEngine.Debug:LogWarning (object)

Photon.Realtime.LoadBalancingClient:DebugReturn (ExitGames.Client.Photon.DebugLevel,string) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2568)

Photon.Realtime.LoadBalancingClient:OnStatusChanged (ExitGames.Client.Photon.StatusCode) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3094)

ExitGames.Client.Photon.PeerBase/<>c__DisplayClass109_0:b__0 () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:1181)

ExitGames.Client.Photon.TPeer:DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/TPeer.cs:237)

ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1771)

Photon.Pun.PhotonHandler:Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:222)

Photon.Pun.PhotonHandler:FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:145)

Any help or advice would be much appreciated! I'll go scour that checklist now...!

2022-01-08 11:29:04

Verify that you are using same AppId in all clients. -> *** Yes, checked. This is all in the same Unity Project.

Verify that clients are connected to the same Region. -> *** Currently addressing this, getting the 'Got a unexpected Disconnect in LoadBalancingClient State' error above.

Verify that you are using same AppVersion in all clients. -> *** Yes, checked. One build is being used for everything.

Verify that players have different unique UserIDs. -> *** As far as I can tell, these should be unique. I'm not setting the UserIDs in code, so Photon should be assigning GUIDs as Ids.

Before trying to join a room by name, make sure that this room is created. Alternatively use JoinOrCreateRoom -> *** Doing this at the moment, unfortunately can't test it as I currently have the Region-related bug mentioned above.

If you are trying to join a random room, make sure to choose the same lobby (name and type) used when creating it -> *** Don't think I'm joining a random room, I'm specifying a particular code per room creation and having the client join that specific room.

If you are doing random matchmaking using room properties as a filter make sure to set the keys of those properties to be visible from the lobby when creating the room -> *** Not doing this.

If you are doing random matchmaking with SQL filters make sure to set the reserved filtering properties keys used to be visible from the lobby. It is also important to relax the SQL filter with each random matchmaking attempt or use chained filters or create new rooms at some point after a number of failed attempts -> *** Not doing this either.

If you are implementing asynchronous matchmaking, make sure to use webhooks with proper configuration (enable "AsyncJoin") or use AsyncRandomLobby. -> *** Not doing this, but have set PhotonNetwork.AutomaticallySyncScene to true (it shares the letters 'sync'!).

Again, more than happy to provide code, etc. Will be hanging around your Discord and trying to find answers to this.

Back to top