Photon JoinedRandomRoom failed; Not ready for operations!

Good evening.
I just recently started reading about PUN and I have to say I'm excited to learn, but as I was following the Pun Basics Tutorial I came accross an odd error, namely:
JoinRandomRoom failed. Client is on MasterServer (must be Master Server for matchmaking) but not ready for operations (State: ConnectingToNameServer). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
After stepping into my code, I noticed this error gets gets called once I step over this piece:
public void connect()
          // Keep track of the will to join a room
          isConnecting = PhotonNetwork.ConnectUsingSettings();


          //we check if we are connected or not
          if (PhotonNetwork.IsConnected)
                    // #Critical: we need to attempt joining a Random Room.
                    // #Critical: If not connected, we must first connect to Photon Online Server.
                    PhotonNetwork.GameVersion = gameVersion;

Which makes me wonder, is JoinRandomRoom(); being called when it's not supposed to? How can I fix this error? Other than that, my game then continues to run succesfully and I'm able to join the correct room based on how many others have joined.

Furthermore, if I try changing the username once I exit a room and return to the main menu I am getting this error:
Operation SetProperties (252) not allowed on current server (MasterServer)

I guess this has to do with the OnChange event related to the InputField. Is there a fix for this?

Thank you very much!


  • Hi @_Paf,

    Thank you for choosing Photon!

    Regarding the first issue, I think it's due to a small misunderstanding in tutorial part 4 where we add "isConnecting" field. We will update it to clarify and avoid this.
    For the time being, you could fix it like shown in this comment.

    For the second issue, could you share the whole stack trace of the error you get when setting username outside of rooms? In theory PUN should allow this and cache the value locally to be used when joining the next room.
    Is this part of the tutorial or custom code?
  • Thank you very much for replying.
    JohnTube wrote: »
    For the time being, you could fix it like shown in this comment.
    I will take a look, thank you, I wasn't aware of this post. I probably didn't search thoroughly.

    On the second matter, this only happens after I return to the Launcher Scene and not on the first time. This is the error I'm getting.
    Operation SetProperties (252) not allowed on current server (MasterServer)
    Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2297)
    Photon.Realtime.LoadBalancingClient:CheckIfOpCanBeSent(Byte, ServerConnection, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2225)
    Photon.Realtime.LoadBalancingClient:OpSetPropertiesOfActor(Int32, Hashtable, Hashtable, WebFlags) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1800)
    Photon.Realtime.Player:SetPlayerNameProperty() (at Assets/Photon/PhotonRealtime/Code/Player.cs:440)
    Photon.Realtime.Player:set_NickName(String) (at Assets/Photon/PhotonRealtime/Code/Player.cs:89)
    Photon.Realtime.LoadBalancingClient:set_NickName(String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:545)
    Photon.Pun.PhotonNetwork:set_NickName(String) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:349)
    Com.MyCompany.MyGame.PlayerNameInputField:SetPlayerName(String) (at Assets/Scripts/PlayerNameInputField.cs:61)
    UnityEngine.EventSystems.EventSystem:Update() (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/EventSystem.cs:377)
  • Hi @_Paf,

    About second issue, could you try out the solution in here.
  • JohnTube wrote: »
    Hi @_Paf,

    About second issue, could you try out the solution in here.

    Thanks for the reference.
  • I would like to know how you "return to launcher scene". Is that LeaveRoom() or ...?
  • I believe so yes, that's how it's done in the PUN Basics Tutorial, see here.

    @_Paf can confirm.