How do I resolve this Photon Error: Operation failed: OperationResponse 226: ReturnCode: 32758 (Game does not exists).
I'm trying to: If all rooms are full or there are no rooms: Create a room with a 2 player max and join it. Else randomly join room.
Here is my code:
using UnityEngine;
using Photon;
public class MyMatchMaker : Photon.PunBehaviour
{
private PhotonView myPhotonView;
public void Start()
{
PhotonNetwork.autoJoinLobby = true;
Debug.Log("Connecting to photon server...");
PhotonNetwork.ConnectUsingSettings("0.1");
}
public override void OnConnectedToPhoton()
{
Debug.Log("Connected to Photon.");
}
public override void OnJoinedLobby()
{
Debug.Log("Connected to Lobby.");
//Pre-setup options for the room you are about to create.
RoomOptions options = new RoomOptions();
options.maxPlayers = 2;
//create the room w those options
if (PhotonNetwork.CreateRoom("0", options, TypedLobby.Default))
{
Debug.Log("Created new Room.");
}
//this should join room 0 as there should not be any other rooms available.
PhotonNetwork.JoinRandomRoom();
}
public void OnPhotonRandomJoinFailed()
{
Debug.Log("Join Random Room Failed.");
//Pre-setup options for the room you are about to create.
RoomOptions options = new RoomOptions();
options.maxPlayers = 2; // 2 player limit.
//create the room w those options
PhotonNetwork.CreateRoom("1", options, TypedLobby.Default);
PhotonNetwork.JoinRandomRoom();
}
public override void OnJoinedRoom()
{
if (PhotonNetwork.room != null)
Debug.Log("Connected to room: " + PhotonNetwork.room);
else
Debug.Log("Not in a room.");
GameObject player = PhotonNetwork.Instantiate("Character", Vector3.zero, Quaternion.identity, 0);
}
}
When I run it, Photon gives me this error:
Operation failed: OperationResponse 226: ReturnCode: 32758 (Game does not exists). Parameters: {} Server: GameServer UnityEngine.Debug:LogError(Object) NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1157) ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[]) ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:125)
Interestingly enough, if I remove the two lines that say: PhotonNetwork.JoinRandomRoom(); It runs, but if there are more than two players I get another error:
Operation failed: OperationResponse 227: ReturnCode: 32766 (A game with the specified id already exist.). Parameters: {} Server: $$anonymous$$asterServer UnityEngine.Debug:LogError(Object) NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1157) ExitGames.Client.Photon.PeerBase:Deserialize$$anonymous$$essageAndCallback(Byte[]) ExitGames.Client.Photon.EnetPeer:DispatchInco$$anonymous$$gCommands() ExitGames.Client.Photon.PhotonPeer:DispatchInco$$anonymous$$gCommands() PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:125)
Please check out the demos and this page: https://doc.photonengine.com/en/pun/current/tutorials/matchmaking-and-lobby
You should avoid using rooms with hard-coded names. While they are full, you're out of luck joining them. If you create a room, the creating client will automatically enter (join) the room, too. So you never need to have CreateRoom() and JoinRandom() right after another.
I write this as comment, because I'm not actively fixing anything you posted but you should now be able to fix things.
@tobiass I fixed the issue by setting hosting region to 'asia' ins$$anonymous$$d of 'best'. Is it right solution?
Answer by Unity_scat · Oct 26, 2016 at 04:30 AM
If you replace Join or JoinRoom with JoinOrCreateRoom, you should just avoid the problem and the need for OnPhotonJoinFailed or OnPhotonRandomJoinFailed.
That's not the point we need to join a specific room actually ,I have the same issue I even I've done all the possible ways to solve but still dont know the real reason behind