PhotonNetwork.JoinRoom problem

Options
Hi,

I've got problem with JoinRoom(name) function.

I want to join room by name when someone else created private room and share room name.

It's working fine but I've got weird problem.

When I try to join room by name and this room doesn't exist then I expected I should receive message that room doesn't exist and I cannot join it but instead this room is created. I thought it should work like that in JoinOrCreate rather than in JoinRoom.

Can anyone help me?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @ByQ,

    Thank you for choosing Photon!

    Maybe you thought the room no longer exist but it's still there.
    Empty rooms (no active/joined actor) stay in Photon servers memory for EmptyRoomTTL before they get disposed.

    Try calling JoinRoom with a new unused room name.
  • ByQ
    Options
    Thanks for contact.

    I'm calling JoinRoom with unused name. I don't know why it happens. It's weird.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Do you use webhooks with AsyncJoin?
  • ByQ
    Options
    No. I dont know what is wrong. I will inspect my code then.
  • ByQ
    Options
    Anyways it's working fine when room is not open (room.isOpen = false). Then i receive OnPhotonJoinRoomFailed with message that room is closed but it doesn't when room don't exist
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @ByQ,

    What PUN version is this?
    Can you share code snippet of how you join a room?
    Try a random room name:
    string shortGuid = Convert.ToBase64String(Guid.NewGuid().ToByteArray())
                .Substring(0, 22)
                .Replace("/", "_")
                .Replace("+", "-");
    PhotonNetwork.JoinRoom(shortGuid);
  • ByQ
    Options
    Hi, I've got latest Photon PUN from Asset Store. Today updated (removed old files and imported new) and same problem.

    I have added your code in onConnectedToMaster() instantly after connected to master server and it creates room - very weird.

    This is my logcat:



    It even doesn't call OnPhotonJoinRoomFailed or OnCreatedRoom it just joins room that doesn't exists and is empty (you can see my log that after joined room there is only 1 player (me) and no opponents).


  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2017
    Options
    so you are using PlayFab.
    the screenshot shows Unity Editor console logs and not (Android's) logcat.

    OK try this code:
    void OnConnectedToMaster()
    {
                string shortGuid = Convert.ToBase64String(Guid.NewGuid().ToByteArray())
                            .Substring(0, 22)
                            .Replace("/", "_")
                            .Replace("+", "-");
                Debug.Log(string.Format("trying to join room \"{0}\"", shortGuid));
                if (!PhotonNetwork.JoinRoom(shortGuid))
                {
                            Debug.LogError("Failed to send join request");
                }
    } 
    
    void OnJoinedRoom()
    {
                Debug.Log(string.Format("Joined room \"{0}\"", PhotonNetwork.room.Name));
    }

    is this related to the other discussion here?
  • ByQ
    Options
    Yes, I'm using PlayFab. This is Log:



    I think that in second disussion problem is similar but not same. In my case all I need is to just receive error when trying to join room that doesn't exist.




  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    OK @ByQ thank you for your time and patience.
    I managed to reproduce with a PlayFab TitleID and Photon AppID.
    We will investigate further and let you know.
    I apologize about the inconvenience.
  • ByQ
    Options
    OK thank you. Is there any estimated time it will be fixed?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2017
    Options
    We are discussing it now, I can't help you.
    We can if you agree update your webhooks config to fix this from config but it's a "workaround".
    The idea is to disable Persistence by setting "IsPersistent = false".
    If you agree let me know by sending your AppId via private message on the forum.

    Do you know when you started to see/have this issue?
    When did you first spot it?
  • ByQ
    Options
    I have just started to implement this feature in my game and got that problem. I didn't notice it before because I didn't create private rooms before.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Another fix is to change CloudScript as follows:
    handlers.RoomCreated = function (args) 
    {
        if (args.Type === "Load") 
        {
            return {ResultCode: 1, Message: "Room does not exist!"};
        }
    }
  • ByQ
    Options
    JohnTube said:

    Another fix is to change CloudScript as follows:

    handlers.RoomCreated = function (args) 
    {
        if (args.Type === "Load") 
        {
            return {ResultCode: 1, Message: "Room does not exist!"};
        }
    }
    Where should I put this code?
  • ByQ
    Options
    Nevermind. I found it on Playfab dashboard. Thank you.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @ByQ,

    Did the change fix the issue for you?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    hi @ByQ,

    It turns out AsyncJoin is enabled by default (true) when IsPersistent is enabled (true) for any webhooks version.
    We can disable it for you by updating the webhooks settings for your app. Just send me your Realtime AppId via message.
    I apologize about the inconvenience.
  • Guts
    Options
    I had the exact same issue several months ago that I was trying to debug with someone who works at Photon via email for weeks, we were never able to find a resolution for the issue. I even created a new simple project to make sure there was not a mistake I was overlooking in my project code. My temporary solution was to write a hack in my client code to get around it but it was not something I felt comfortable with for the long term.

    It looks like adding that conditional statement to my CloudScript fixed the problem and that makes me happy. @JohnTube is there a more permanent solution planned for this in the future?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited October 2017
    Options
    Hi @Guts,

    I apologize about the inconvenience!

    Please reply to the same email thread with your AppId and reference this forum discussion.
    The right thing to do to avoid the AsyncJoin behaviour is that we or PlayFab update the webhooks settings for your app with a new key/value "AsyncJoin" = "false".
  • Guts
    Options
    Hi @JohnTube, thank you for the quick reply! I did exactly what you requested, it should be popping up in the developer email box soon.
  • wtdunity
    Options
    -> on call joinRoom got Error Operation failed: OperationResponse 226 before call Photon event OnPhotonJoinRoomFailed(object[] codeAndMsg). i just want to show message if room is not available to join.

    if (!PhotonNetwork.JoinRoom("RoomNameTest"))
    {
    txt_ValidateErrorMsg_Join.text = "Fail to Join Room...!";
    }
    -------------------

    Operation failed: OperationResponse 226: ReturnCode: 32758 (Game does not exists). Parameters: {} Server: MasterServer
    UnityEngine.Debug:LogError(Object)
    NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1621)
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)
  • matrix211v2
    Options

    Hello

    I'm having the same problem in that trying to join a room that doesn't exist creates one.

    What is the workaround or the correct way to handle it? Using PUN2 with PlayFab

    Thanks

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options

    Hi @matrix211v2,

    Set AsyncJoin : false from web hooks settings.