Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

“operation set (252) not called because client is not connected” And I have one more problem.

Discussion in 'Multiplayer' started by GamegangsterBG, May 10, 2020.

  1. GamegangsterBG

    GamegangsterBG

    Joined:
    May 27, 2019
    Posts:
    3
    Hello, I just started using PUN 2 and recently I made a pause menu to my multiplayer game and in the pause menu there is a Disconnect button.

    Code (CSharp):
    1.  
    2. public void Disconnect()
    3. {
    4. PhotonNetwork.LeaveRoom();
    5. SceneManager.LoadScene(0);
    6. }
    And when I press the button i get this error “ operation set (252) not called because client is not connected or not ready yet. client state leaving”. I am wondering does that mean that my player is not fully connected, because I am having another problem which is that sometimes only one of the players sees the player, does it have something to do with the error and how can I fix both issues? Thanks in advance!
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    We found an issue with SetProperties recently and fixed it in PUN 2.18.1. Maybe you update and give it another go.
    If this is v2.18.1, we'd need to know more about the timing of this use case.
    After leaving a room, we need to apply properties locally but not send them. This check apparently isn't working in your case.
     
  3. GamegangsterBG

    GamegangsterBG

    Joined:
    May 27, 2019
    Posts:
    3
    Hello, thanks for the reply! I am using PUN 2.18.1 and sometimes when I press disconnect and I get the error but then it does not go back to the menu scene.
     
  4. GamegangsterBG

    GamegangsterBG

    Joined:
    May 27, 2019
    Posts:
    3
    Do you know how to fix the error? If so, how?
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    You should stop calling the operation (with code 252) once you disconnect. Apparently your code continues to call it.
    Along with the error code, you get a callstack. Check which code called the operation and make sure it only runs while connected.
     
  6. Seven007

    Seven007

    Joined:
    Aug 19, 2013
    Posts:
    5
    @tobiass I have been having this problem. So far I have checked. It seems the PhotonMono is still not destroyed.
    Scenario:
    After the multiplayer match is done. Result screen is showed, then clicking back to go to main menu is causing this issue. before calling main menu scene. I called leave room & Disconnect. But, when it reaches mainmenu. PhotonMono GO is not destroyed and its calling PhotonNetwork.NewSceneLoaded(); at Start().

    Why PhotonMono is not destroyed. Am I doing something wrong?

    Code (CSharp):
    1. public void OnLoadMainMenu ()
    2.     {
    3.           PhotonNetwork.LeaveRoom();
    4.           PhotonNetwork.Disconnect();
    5.           SceneManager.LoadScene(1);
    6.     }
    After looked into some other forums. I have tried this code:
    Code (CSharp):
    1. private IEnumerator WaitForDisconnect ()
    2.     {
    3.         PhotonNetwork.LeaveRoom();
    4.         PhotonNetwork.Disconnect();
    5.         while (PhotonNetwork.IsConnected)
    6.             yield return 0;
    7.         SceneManager.LoadScene(1);
    8.     }
    But, that stays in the multiplayer scene and never leaves.

    Help me out!

    Thanks!
     
    Last edited: Jun 4, 2020
    siddharth3322 likes this.
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    PhotonMono is PUN's integration with Unity engine events. Some are only available to MonoBehaviours, so PhotonMono is created at runtime and marked with DontDestoryOnLoad. It has to stay there, even when you disconnect.
     
  8. Seven007

    Seven007

    Joined:
    Aug 19, 2013
    Posts:
    5
    @tobiass Ya, But, when it loads back to main menu from Multiplayer scene (Where I called Leave Room & Disconnect).
    Photon Network call is initiating from the start of that function.

    So, that's what causing me the issue Operation set (252)
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    A callstack might help.
     
  10. Zehs

    Zehs

    Joined:
    Mar 16, 2019
    Posts:
    3
    @Seven007 What's happening is that you're leaving the scene too quickly.

    Use this.

    Code (CSharp):
    1. public void LeaveRoom()
    2. {
    3.     PhotonNetwork.LeaveRoom();
    4. }
    5.  
    6. public override void OnLeftRoom()
    7. {
    8.     SceneManager.LoadScene(0);
    9.  
    10.     base.OnLeftRoom();
    11. }
    Also make sure you are using MonoBehaviourPunCallbacks
     
  11. CPUCPU

    CPUCPU

    Joined:
    Nov 15, 2019
    Posts:
    10
    I'm getting the same issue. It seems to only happen when I'm trying to rejoin a room.

    As you can see in my logs, isConnectedAndReady is TRUE before I attempt to call RejoinRoom. And despite getting the error, it still successfully joins the room afterward.



    I'm using PUN 2.18.1 on 2019.3.12f1
     
  12. Ekta-Mehta-D

    Ekta-Mehta-D

    Joined:
    Feb 25, 2013
    Posts:
    24
    Hii. Did you solve your issue guys? I am facing the same.
     
  13. oludev97

    oludev97

    Joined:
    Apr 8, 2019
    Posts:
    3
    yes i solved it by following this
     
    LizhengheChen and siddharth3322 like this.
  14. Ekta-Mehta-D

    Ekta-Mehta-D

    Joined:
    Feb 25, 2013
    Posts:
    24
    Ok. Solved, Thanks. :)
     
  15. anmol07goyal

    anmol07goyal

    Joined:
    Jan 19, 2020
    Posts:
    2
    That really worked. Thanks man:)
     
  16. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Hi,

    i am having exactly the same situation ( game pause menu, was trying to load menu too quickly ).

    However when i call this:
    Code (CSharp):
    1. if (PhotonNetwork.InRoom)
    2.     PhotonNetwork.LeaveRoom();
    the LeftRoomCallback doesn't get called
    Code (CSharp):
    1.  
    2. // Dasn't get called because player gets deleted
    3. public override void OnLeftRoom()
    4. {
    5.     PhotonNetwork.LoadLevel("Menu");
    6. }
    because the player gets deleted and i get this log message:
    Network destroy Instantiated GO: Car_01(Clone)1001

    Is it normal that the player gets deleted in this case, because i thought it has to be deleted manually ?
     
  17. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    By default, networked game objects are cleaned up (destroyed) when the creator leaves.

    You can disable the clean up entirely. Set RoomOptions.CleanupCacheOnLeave = true when you create a room.

    It's also possible for the Master Client to instantiate "Room Objects", which stay in the room, you can load networked objects with the scene.
     
  18. ClearRoseOfWar

    ClearRoseOfWar

    Joined:
    Sep 6, 2015
    Posts:
    87
    public void OnClick_RestartGame()
    {
    PhotonNetwork.LeaveRoom();
    }

    public override void OnLeftRoom()
    {
    SceneManager.LoadScene("Lobby");

    base.OnLeftRoom();
    }

    I have my restart game attached to a button, with the above code. Yet, I can't seem to get this to work. What am I doing wrong? I just want to load from game scene back to lobby scene.
     
  19. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Is this PUN 2? The script which implements OnLeftRoom seems to extend MonoBehaviourPunCallbacks? Make sure this script's OnEnable() / OnDisable() call base (so they get registered for the callback).

    Enable the SupportLogger in the settings and check if that also doesn't log OnLeftRoom().
     
  20. noamiko121212

    noamiko121212

    Joined:
    Feb 18, 2021
    Posts:
    8
    Hi I have the same issue but a bit forward so I called (PhotonNetwork.LeaveRoom();) and then the game freeze and its not disconnecting, there is no error and the player have being destroy like it should be but its just stop.
    look:
     

    Attached Files:

  21. noamiko121212

    noamiko121212

    Joined:
    Feb 18, 2021
    Posts:
    8
    Someone can help maybe?
     
  22. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    There is no known reason why this should happen due to PUN. Can you reproduce this with any of the samples we provide with the package?
    Is there a newer version of PUN which you could update to? And which version of Unity is this?
     
  23. noamiko121212

    noamiko121212

    Joined:
    Feb 18, 2021
    Posts:
    8
  24. noamiko121212

    noamiko121212

    Joined:
    Feb 18, 2021
    Posts:
    8
    i am using pun 2 so i think its the newer version no?
     
  25. noamiko121212

    noamiko121212

    Joined:
    Feb 18, 2021
    Posts:
    8
    there is something that may cause this issue?
     
  26. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    I think the issue is somehow caused within your project, not by PUN itself. So please try to reproduce with one of our demos. If you can, we can have a look.

    PUN 2 also has a version number. Look at PhotonNetwork.PunVersion.
     
  27. noamiko121212

    noamiko121212

    Joined:
    Feb 18, 2021
    Posts:
    8
    I will tell you what, this is happening only in the game scene in the menu i have also leave Room button that program the same and he works
     
  28. noamiko121212

    noamiko121212

    Joined:
    Feb 18, 2021
    Posts:
    8
    So i have no idea why this is happening
    .
     
  29. habibizeinab9

    habibizeinab9

    Joined:
    Jul 5, 2020
    Posts:
    2
    hi, I have this issue. I call changing scene in OnLeftRoom Method and it's working without error. so o think you cant call changing scene before the LeaveRoom method sends the callback.



    public void LeaveRoom()
    {
    PhotonNetwork.LeaveRoom();
    }



    public override void OnLeftRoom()
    {
    SceneManager.LoadScene("Menu-Scene");
    }
     
  30. noamiko121212

    noamiko121212

    Joined:
    Feb 18, 2021
    Posts:
    8
  31. georsavvides

    georsavvides

    Joined:
    Jun 15, 2019
    Posts:
    2
    In my case, I was getting this error when I was re-joining a room with a different "nickname"(or possible other player properties). Keeping the same nickname when rejoining rooms has solved the problem.
     
    What1sThat_VALEN_ likes this.
  32. dmitriybelousov33

    dmitriybelousov33

    Joined:
    Oct 13, 2021
    Posts:
    1
  33. thundermircea

    thundermircea

    Joined:
    Dec 16, 2016
    Posts:
    6
    I've been having the same problem and found the FIX
    So basically the problem is you're calling scenemanager.loadscene before photon manages to disconnect from the room, what you should do instead is just call PhotonNetwork.LeaveRoom()
    The inside of the "public override void OnLeftRoom()" you should add the scene changin code

    also to be able to use that callback you'll need your class to inherit from MonoBehaviourPunCallbacks

    EXAMPLE

    I was getting this error on

    Code (CSharp):
    1.     public void leaveServer()
    2.     {
    3.  
    4.         SceneManager.LoadScene("MainMenu");
    5.  
    6.         PhotonNetwork.LeaveRoom();
    7.     }
    So I just replaced it with

    Code (CSharp):
    1.     public void leaveServer()
    2.     {
    3.  
    4.         PhotonNetwork.LeaveRoom();
    5.  
    6.     }
    7.     public override void OnLeftRoom()
    8.     {
    9.         SceneManager.LoadScene("MainMenu");
    10.     }
     
    tobiass likes this.
  34. Weryx

    Weryx

    Joined:
    Jun 3, 2021
    Posts:
    1
    Hello, thank you for the recommendation, this has helped, but in my case I have encountered a new problem.
    When I connect to the lobby this error occurs:
    Operation JoinLobby (229) not called because client is not connected or not ready yet, client state: JoiningLobby

    Based on this forum post, I found out that this is caused by me running the JoinLobby() function twice:
    https://forum.photonengine.com/discussion/17696/problem-joinlobby

    I call it in the OnConnectedToMaster() method and then in the Start() method,
    Without it being called in OnConnectedToMaster, it all falls apart.
    Without it being called in Start, players after a fresh connection can't see the rooms listed. They have to create their own room and leave it (so then the OnConnectedToMaster() is called and they are connected to the lobby), so the OnConnectedToMaster method is not called after fresh connection... which strikes me as odd.

    I somehow tried to check if I'm connecting to Lobby but it did not help (I guess PhotonNetwork.InLobby returns false while joiningLobby)
    I tried this:

    Code (CSharp):
    1.  private void Start()
    2.     {
    3.         StartCoroutine(waitToConnect());
    4.     }
    5.  
    6.     IEnumerator waitToConnect() {
    7.         while(!PhotonNetwork.IsConnectedAndReady)
    8.             yield return null;
    9.         roomInputField.characterLimit = 13;
    10.         if (!PhotonNetwork.InLobby) PhotonNetwork.JoinLobby();
    11.     }
    Error persisited, so I brute-forced it like this:

    Code (CSharp):
    1. private void Start()
    2.     {
    3.         StartCoroutine(waitToConnect());
    4.     }
    5.  
    6.     IEnumerator waitToConnect() {
    7.         while(!PhotonNetwork.IsConnectedAndReady)
    8.             yield return null;
    9.         roomInputField.characterLimit = 13;
    10.         StartCoroutine(waitASec());
    11.     }
    12.  
    13.     IEnumerator waitASec() {
    14.         yield return new WaitForSeconds(1f);
    15.         if (!PhotonNetwork.InLobby) PhotonNetwork.JoinLobby();
    16.     }
    This helped with the error, but with this solution, after rejoining the lobby scene, after the match ended. The players can't see new rooms (so I would guess they are not connected to the lobby), but this time creating a new room and leaving it won't help.

    I would be grateful for any insights and comments!
     
  35. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Refactor your code to rely on the PUN callbacks. IsConnectedAndReady is not covering all the cases you want to be aware of. You can inherit from MonoBehaviourPunCallbacks and override the individual methods (they are empty in the base). So you know when you arrived on the Master Server, joined a lobby, etc.
     
  36. shahroziub

    shahroziub

    Joined:
    Sep 8, 2019
    Posts:
    21
    How to fix this issue,i'm using PUN2?
    "Operation ChangeGroups (248) not allowed on current server (MasterServer)"
     
  37. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Do not call this on the Master Server. Only in a room.