question

quanpn82 avatar image
quanpn82 asked

handlers.RoomJoined web hook not be called when call PhotonNetwork.JoinRoom();

Hi @Brendan and @Hamza Lazaar

I try to join room what created by other device before. But when I call PhotonNetwork.JoinRoom("RoomName") from second device, handlers.RoomJoined not be called. Instead Photon call RoomCreated web hook.

I am sure the room have exist and I still can rejoin in first device.

Pls give me some suggestion to track the issue

Thank you

Quan

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hamza Lazaar avatar image
Hamza Lazaar answered

Hi @quanpn82,

I have checked the project you sent me. I could not reproduce what you described (second player creates a room). You can check the PlayStream events.

Here is what I think is happening:

You are creating two games because:

The two players are on different regions: this explains the different server addresses you observed in the logs.

Other possible reasons for players not being able to find each other:

Different AppVersion for each player.

Different TypedLobby for each player.

Also JoinRoom operation/method should not create new rooms unless you use Rejoin method (ActorNr = -1) or AsyncJoin is configured in webhooks 1.2 but this is unlikely the case as PlayFab still uses webhooks 1.0.

Unless there is a Photon webhooks misconfiguration of your AppID, join room event should trigger RoomJoined handler and not RoomCreated one.

---

Unrelated:

- You don't have to join the lobby to be able to create and join room by name. Maybe you're joining the lobby to list available rooms and get statistics. That should be O.K.

- Do you mix WebRPC and ExecuteCloudScript? Why not choose one and stick with it?


P.S.: Please remove that link and do not share Title IDs and App IDs and other credentials in public please.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

quanpn82 avatar image quanpn82 commented ·

Hi Hamza

Thank for your detail explanation, I found root cause of my problem. I chose Best Region in Photon Setting so devices selected deference Region when connecting server. I specific chose 1 region (asia) in setting and I can join created room from other device.

This is only sample project to study Photon and Playfab so code very mess and I dont care about security for credentials info :)

Thank you so much

Quan

Hi @Brendan, thank for your support too, I think Hamza's answer is best for my problem, please mark it as Best Anwser to help other solve same issue faster.

Thank you

Quan

0 Likes 0 ·
brendan avatar image
brendan answered

What are the Title ID and App ID you are using?

9 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

quanpn82 avatar image quanpn82 commented ·

Hi Brendan

I am using:

TitleId = "3733";

PhotonAppId="515876c3-7702-4a24-b9d8-09ad50895158";

0 Likes 0 ·
brendan avatar image brendan quanpn82 commented ·

Can you provide the code snippet(s) showing how you create a join rooms? @Hamza Lazaar can confirm, but the only time Photon would call RoomCreated is if the room is actually created (wasn't there before).

0 Likes 0 ·
quanpn82 avatar image quanpn82 brendan commented ·

Hi Brendan

This is my code to create and join Room. I ran CreateRoom() on real device and check what room have been created. Then I set room name what have been create in read device in JoinRoom() and ran in editor. I also make sure room have been created in FlayFab Manager and still available until JoinRoom() ran.

I logged in real device with Android Device ID

And in Editor I user customID to login

    // Create new room 

    public void CreateRoom()

    {

        int randnum = UnityEngine.Random.Range (1, 100);

        currentRoomName= "TestRoom" + randnum;    // for int, Random.Range is max-exclusive!

        Debug.Log("CreateRoom() will create: " + currentRoomName);



        RoomOptions demoRoomOptions = new RoomOptions()

        {

            MaxPlayers = 4,

            CustomRoomPropertiesForLobby = RoomPropsInLobby,

//            EmptyRoomTtl = 5000,

            PlayerTtl = 300000

        };

        PhotonNetwork.CreateRoom(currentRoomName,demoRoomOptions,TypedLobby.Default);



    }



    // Join room 

    public void JoinRoom()

    {

        PhotonNetwork.JoinRoom("TestRoom26");



    }
0 Likes 0 ·
Hamza Lazaar avatar image Hamza Lazaar quanpn82 commented ·

Hi @quanpn82

How do you know if any webhook handler is called?

Please if you have a logs per GameId of the webhooks triggered, do share them with us.

I think the room is being "closed" / destroyed between first actor's join (creation) and second actor's join.

What are the EmptyRoomTTL and PlayerTTL values?

0 Likes 0 ·
quanpn82 avatar image quanpn82 Hamza Lazaar commented ·

Hi Hamza

I got error message from Photon Operation response when calling PhotonNetwork.JoinRoom("TestRoom26");

Operation 226 failed in a server-side plugin. Check the configuration in the Dashboard. Message from server-plugin: Failed to load state from https://3733.playfablogic.com/webhook/1/prod/{
                     {cut}}/RoomCreated? : Error response ResultCode='4' Message='PlayFabAPIError InvalidSharedGroupId: InvalidSharedGroupId 

I am sure the room not be closed because I still can re join from first device which have created this the before.

I can not set EmptyRoomTtl for RoomOptions because it not available, refer above code I have to commented it

0 Likes 0 ·
Show more comments
Hamza Lazaar avatar image Hamza Lazaar commented ·

Hey @quanpn82

Please find a way to log webhooks calls from CloudScript to understand what's going on.

All I can say is that you have a RoomClosed and RoomLeft webhooks being triggered somewhere in between the 2 RoomCreated webhooks.

I personally use loggly.

You can also tell PlayFab to change your BaseURL to make use of runscope.

0 Likes 0 ·
quanpn82 avatar image quanpn82 Hamza Lazaar commented ·

Hi Hamza

I prepared a project to help you reproduce my issue here: [cut]

I raise event log in PlayFab manager every calling webhooks in script but not found any room closed event

I found something new in my problem:

1. I call PhotonNetwork.GetRoomList() in OnJoinedLobby() and not found any room have been created before when I run on second device

2. I log PhotonNetwork.ServerAddress after connect to Photon and found out ServerAddress on 2 devices is difference

I connected Photon by below function:

PhotonNetwork.ConnectUsingSettings(PhotonAppVersion);

And set Hosting is Best Region in Photon Setting screen-shot-2016-09-20-at-114459-pm.png

Please help me check in sample project have something wrong

Thank you so much

Quan

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.