getting errors when setting up game to connect to photon

Options
Hello,

Trying to get my game to connect to photon, but it is giving the following 2 errors:
1. CreateRoom failed. Client is on NameServer (must be Master Server for matchmaking)but not ready for operations (State: ConnectingToNameServer). Wait for callback: OnJoinedLobby or OnConnectedToMaster.

2. GetRegions failed. Can't provide regions list. ReturnCode: -2: Empty application id

here is what i have right now for the C# code, maybe i am missing something OR not needed?
    public void ConnectToPhoton()
    {
        AppSettings apsettings = new AppSettings();
        apsettings.AppVersion = "0.0.0.1";
        apsettings.Protocol = ExitGames.Client.Photon.ConnectionProtocol.Udp;
        PhotonNetwork.GameVersion = "0.0.0.1";
        apsettings.FixedRegion = string.Empty;
        apsettings.UseNameServer = true;
        Debug.Log("Connecting to Photon.");
        PhotonNetwork.ConnectUsingSettings(apsettings, false);
    }

    public override void OnConnectedToMaster()
    {
        PhotonNetwork.AutomaticallySyncScene = false;
        PhotonNetwork.JoinLobby(TypedLobby.Default);
        Debug.Log("Connected Successfully to Photon");
    }

    public override void OnDisconnected(DisconnectCause cause)
    {
        Debug.Log("Disconnected to Photon, reason: " + cause.ToString());
    }


also the ConnectToPhoton() gets called first then the settings of the lobby like so:
   public void OnClick_CreateRoom()
    {
        //Connect to Photon First...
        ConnectToPhoton();
        //If NOT connected, dont proceed
        if (!PhotonNetwork.IsConnected)
        {
            return;
        }

        // IF Connected, then use the following settings...
        RoomOptions options = new RoomOptions();
        
        if(HideRoom_toggle.isOn)
        {
            options.IsVisible = true;
        }
        else
        {
            options.IsVisible = false;
        }

        //Hide Room checked?
        if(RoomPlayerCount == 1)
        {
            options.IsOpen = false;
        }
        else
        {
            options.IsOpen = true;
        }

        options.EmptyRoomTtl = 600;
        options.PlayerTtl = 600;

        //Check how many players
        options.MaxPlayers = RoomPlayerCount;

        if(_roomName is null || _roomName.text.ToString() == string.Empty)
        {
            messageText.text = "Room Name cannot be empty";
            return;
        }
        else
        {
            createRoomButton.interactable = false;
            PhotonNetwork.CreateRoom(_roomName.text, options, TypedLobby.Default);
        }
    }

do i need to have the client be connected already prior to calling the creation of a lobby?

Comments

  • siten0308
    Options
    OK So NOW i tried to use the Demo Asteroids that it comes with.. STILL SAME PROBLEM!!!!! error message below:

    CreateRoom failed. Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.

    I am using script LobbyMainPanel found with photon under PhotonUnityNetworking, then DemoAsteroids, the on scripts, called LobbyMainPanel, i use the method: OnCreateRoomButtonClicked... and seems to work fine on asteroids, but on mine... That error message keeps coming... WHY???!!!
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @siten0308,

    Thank you for choosing Photon!

    You are not setting an AppId!
    If you connect to Photon Cloud you need to set an AppId.

    So do this
    public void ConnectToPhoton()
        {
            AppSettings apsettings = new AppSettings();
            apSettings.AppId = "<PASTE_YOUR_APPID_HERE"; // must be of valid type, Realtime or PUN
            apsettings.AppVersion = "0.0.0.1";
            apsettings.Protocol = ExitGames.Client.Photon.ConnectionProtocol.Udp;
            PhotonNetwork.GameVersion = "0.0.0.1";
            apsettings.FixedRegion = string.Empty;
            apsettings.UseNameServer = true;
            Debug.Log("Connecting to Photon.");
            PhotonNetwork.ConnectUsingSettings(apsettings, false);
        }
    
    or this (and setup PhotonServerSettings scriptabe object in the project):
    public void ConnectToPhoton()
        {
            Debug.Log("Connecting to Photon.");
            PhotonNetwork.ConnectUsingSettings();
        }
    
  • siten0308
    Options
    thanks for the info, though i dont see "apSettings.AppID" i do see realtime, but also when i do put my appID into or realtime, now the new error message says:

    PUN is in development mode (development build). As the 'dev region' is not empty (usw) it overrides the found best region. See PhotonServerSettings.

    OperationResponse 230: ReturnCode: 32755 (Failed to parse token from request). Parameters: {} Server: NameServer Address: ns.exitgames.com:5058

    I left the region black, or in this case, string.empty, should i put something there for the sake of development? also what is the second error about token from request?

    I did forget to mention i am trying to integrate with playfab... should I not?