Bug in joining players in one room

Hello, I am using a code that is based on join or create a room (PUN2). At the moment of the game, the player enters a room and is looking for a player (and in the other game window), he is still looking for an opponent, even though both players are in the rooms.
It seems to me that the problem is that the player is not sending information about presence in the room, but how can I fix this?

using Photon.Pun;
using Photon.Pun.Demo.Cockpit;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

public class GlobalMenu : MonoBehaviourPunCallbacks
{
    [SerializeField] private GameObject findOpponentPanel = null;
    [SerializeField] private GameObject waitingStatusPanel = null;
    [SerializeField] private TextMeshProUGUI  waitingStatusText= null;

    private bool isConnecting = false;

    private const string GameVersion = "1.6";
    private const int maxPlayersPerRoom = 2;

    private void Awake() => PhotonNetwork.AutomaticallySyncScene = true;

    public void FindOpponent()
    {
        isConnecting = true;
        findOpponentPanel.SetActive(true);
        waitingStatusPanel.SetActive(true);

        waitingStatusText.text = "Searching ...";

        if(PhotonNetwork.IsConnected)
        {
            PhotonNetwork.JoinRandomRoom();
        }
        else
        {
            PhotonNetwork.GameVersion = GameVersion;
            PhotonNetwork.ConnectUsingSettings();
        }
    }

    public override void OnConnectedToMaster()
    {
        Debug.Log("Connected To Master");

        if(isConnecting)
        {
            PhotonNetwork.JoinRandomRoom();
        }
    }

    public override void OnDisconnected(DisconnectCause cause)
    {
        waitingStatusPanel.SetActive(false);
        findOpponentPanel.SetActive(true);

        Debug.Log($"Disconnect due to: {cause}");
    }

    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        Debug.Log("No clients are waiting for an opponent, creating new room");

        PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = maxPlayersPerRoom }, null);
    }

    public override void OnJoinedRoom()
    {
        Debug.Log("Client successfully joined a room");

        int playerCount = PhotonNetwork.CurrentRoom.PlayerCount;

        if (playerCount != maxPlayersPerRoom)
        {
            waitingStatusText.text = "Wainting For Opponent";
            Debug.Log("Client is waiting for an opponent");
        }
        else
        {
            waitingStatusText.text = "Opponent Found";
            Debug.Log("Matching is ready to begin");
        }
    }

    public override void OnPlayerEnteredRoom(Player newPlayer)
    {
        if(PhotonNetwork.CurrentRoom.PlayerCount == maxPlayersPerRoom)
        {
            PhotonNetwork.CurrentRoom.IsOpen = false;
            Debug.Log("Match is ready to begin");

            waitingStatusText.text = "Opponent Found";
            Debug.Log("Match is ready begin");

            PhotonNetwork.LoadLevel("Arena");
        }
    }
}

While I can not help you with your code, I can point you to the Tutorial, which also covers loading scenes for multiple players. Read it and code-along and you should be prepared to tackle this in your code.

Also, the Asteroids Demo in the package has some code for a “i am ready” flag per player. When all players are ready, one can start the round. Just in case you need that.

Thanks, let me review this tutorial. You could only direct me what I should be looking for to match the two players with each other and make them move on to the next scene. I already know it is about sending a signal ready to the server.

I checked the code and examples of other programmers. It follows that everything should be fine, but when the second player starts searching, he doesn’t find the first one who has already created a room. What could be the reason ?