Cannot Join Created Room [SOLVED]

The whole answer can be found below.

Please note: 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! And we offer you support through these channels:

Try Our
Documentation

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.

Read More on
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.

Cannot Join Created Room [SOLVED]

Keely
2020-03-22 13:15:12

I've created a Photon PUN 2 application.
It's successfully connecting to the server, connecting to the lobby and creating a room.
But when I try to open two instances of the application and create a room, the OnRoomListUpdate method isn't being called on the other instance and when I try to join it calls OnJoinRoomFailed with an error saying that the room doesn't exist.

The "0" is the number of rooms that it's finding.
Am using just the word "test" for creating and joining the room, so I'm pretty sure that it's not that the names aren't matching up as far as I can tell. Probably missing something silly but I'm at my wit's end for trying to figure this out on my own.

Comments

Keely
2020-03-22 13:17:18

If you need the code in text format for copying:

    void Start()  
    {  
        if(Instance == null)  
        {  
            Instance = this;  
        }

        if (!PhotonNetwork.IsConnected)  
        {  
            print("Connecting to server..");  
            PhotonNetwork.ConnectUsingSettings();  
        }

    }

    public override void OnConnectedToMaster()  
    {  
        print("Connected to the server.");  
        MainMenuButtons.Instance.ConnectedToServer();  
        PhotonNetwork.AutomaticallySyncScene = false;  
    }

    public override void OnJoinedLobby()  
    {  
        print("Joined lobby.");  
        if (!PhotonNetwork.InRoom)  
        {  
            MainMenuButtons.Instance.JoinedLobby();  
        }  
    }

    public override void OnRoomListUpdate(List<RoomInfo> roomList)  
    {  
        Debug.Log(roomList.Count);  
    }


    public void JoinLobby()  
    {  
        if (!PhotonNetwork.JoinLobby(TypedLobby.Default))  
        {  
            Debug.Log("Failed to join lobby.");  
        }  
          
    }

    public void JoinRoom(string roomName)  
    {  
        Debug.Log("Trying to join room.");  
        if (!PhotonNetwork.JoinRoom(roomName))  
        {  
            Debug.Log("Failed to join room.");  
        }  
    }

    public void LeaveLobby()  
    {  
        PhotonNetwork.LeaveLobby();  
        MainMenuButtons.Instance.LeftLobby();  
    }

    public void LeaveRoom()  
    {  
        PhotonNetwork.LeaveRoom();  
        MainMenuButtons.Instance.LeftRoom();  
    }

    public override void OnJoinedRoom()  
    {  
        print("Joined room.");  
        MainMenuButtons.Instance.JoinedRoom();

        foreach (Transform child in transform)  
        {  
            Destroy(child.gameObject);  
        }

        Player[] photonPlayers = PhotonNetwork.PlayerList;

        foreach (Player photonPlayer in photonPlayers)  
        {  
            MainMenuButtons.Instance.PlayerListings.PlayerJoinedRoom(photonPlayer);  
        }  
    }

    public bool CreateRoom(string roomName)  
    {  
        if (roomnames.Contains(roomName))  
        {  
            return false;  
        }

        RoomOptions roomOptions = new RoomOptions() { IsVisible = true, IsOpen = true, MaxPlayers = 3 };

        PhotonNetwork.CreateRoom(roomName, roomOptions, TypedLobby.Default);  
        Debug.Log("Creating room.");  
        return true;  
    }

irolenze
2020-03-24 15:50:28

I'm sorry but what exactly was the solution?
I am having the exact same issue! The application creates and connects to the room but then when I try to join with others it shows to be creating the room again and when I display the total number of rooms it shows 0 (yes, even after it has connected to the room and hasgone through the OnJoinedRoom). If I list the number of players in the room it shows only 1 player.
Mind you that everything was working yesterday...

EDIT: I don't know why but every thing is working when I connect to the application with an instance running on my phone... It is what I intend to do with the final product so I can work with this but it was working correctly yesterday running on pc too...

NinjaChronicles
2022-10-09 00:00:58

I'm also having this exact issue, was there any resolution to this?

Brainlocks
2022-12-15 20:54:17

This worked for me. I've been struggling with this for the past 3 hours. It worked yesterday and then suddenly stopped today. Here are some steps that might work for you (the code snippet is what ultimately worked best for me):

(Add the code snippet FIRST) Sorry I couldn't figure out how to format it properly.

  • Switch your build file from your OneDrive folder to your Local disk C folder. This should work if you are experiencing the bug where it works in the Unity editor but not in the build. OneDrive automatically autosaves which could be messing with photon on your computer.

  • In your connect to server script make sure that Start void is private, and that the OnConnectedToMaster AND OnJoinedLobby both start with public override void. People often forget to add override which can lead to issues.

  • Restart Computer/ Home network/Unity.

  • Download the 2022 version of unity or some other compatible version

  • Make sure that your player prefab is in a folder specifically named "Resources" with a capital R. Photon WILL NOT load your character for other players if it is not in the "Resources" tab.

  • Good Luck!

dm me @getbenking on twitter if this doesn't work for you.

Inside your Create and Join script add this    
    
void Start()    
    {    
            
if (!PhotonNetwork.IsConnected)    
        {    
            print("Connecting to server..");    
            PhotonNetwork.ConnectUsingSettings();    
        }    
Back to top