The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

OnRoomListUpdate not being called

LuckBringer
2021-02-01 01:35:57

Hi everyone,

After I join a region and create a room TypedLobby.Default, the room doesn't show on the second instance, even though the second instance is on the same region. The fuction OnRoomListUpdate doesn't run.

https://imgur.com/a/2EhPzeU

How can I fix this?

Many thanks,
Gabriel.

Comments

JohnTube
2021-02-01 16:19:58

Hi @LuckBringer,

Thank you for choosing Photon!

Make sure you are using the same AppId, AppVersion and PUN version on both clients.
Also double check the region as if one client is using development build and the other is not could lead to two different regions (dev region vs. fixed region vs. best region).

LuckBringer
2021-02-02 16:11:51

Hi John!

I tried what you described and unfortunately didn't work. Both instances were playing with the same AppId, Pun version and same region.

What type of troubleshooting should I do next, please?

Many thanks,
Gabriel.

JohnTube
2021-02-02 17:57:01

Hi @LuckBringer,

Is the room you created visible?
Check "AppStats and LobbyStats".
OnRoomListUpdate works only when joined to the lobby of default type make sure the client is joined to such lobby and not disconnected and not in a room.

Unrelated notes:
If you extend MonoBehaviourPunCallbacks no need to implement ILobbyCallbacks.
Make sure to follow our example snippet for how to handle rooms list as the callback could contain entries for removed rooms (roomInfo.RemovedFromList == true).

LuckBringer
2021-02-02 21:11:59

Hi John!

I tried to do as you said I believe, even leaving a code after I joined to room to leave it open and visibie as you can see here:
https://imgur.com/a/cTnF8pw

And this is how I create a room:
https://imgur.com/a/QFUnZt4

Anything else I can try?

And thanks for the tip at the end =)

Thanks again John!
Gabriel.

LuckBringer
2021-02-02 23:51:15

Oh and one more thing, when I used PhotonNetwork.CountOfRooms, it was able to find 1 Room, but not able to list it.

JohnTube
2021-02-03 09:15:22

I really don't see why is this happening.
In the class that implement OnRoomListUpdate make sure to call base methods if you override OnEnable or OnDisable. Make sure that script is in the scene hierarchy enabled and attached to an active GameObject.

I see you print/log the Region in some callbacks, maybe add PhotonNetwork.NetworkingClient.AppVersion also.
Otherwise, enable SupportLogger and share (complete) logs from both instances.

LuckBringer
2021-02-04 01:22:52

Hi John,

First of all, I did not understand what you said:
"In the class that implement OnRoomListUpdate make sure to call base methods if you override OnEnable or OnDisable."

Could you please explain it to me?


This is the log of the first instance:
https://imgur.com/a/QnNEyOS

This is the second one:
https://imgur.com/a/ogGFT2M

(I'm using sandboxie to use 2 editors at the same time, sandboxie is a software that allows the user to open any software in a complete closed part of your hard drive, just in case you find strange that I'm sending 2 pictures from Unity Editor)

And as you can see, the second instance can even find that there is one Room with the CountOfRooms, but it doesn't run the function OnRoomListUpdate.

And I am able to connect 2 players together if I just let them join a random room, as you can see from the gameplay from my game:
https://www.youtube.com/watch?v=XJld6gyifpA&ab_channel=InitiativeVR

Just the listing of the rooms that isn't working.

Many thanks once again,
Gabriel.

JohnTube
2021-02-11 08:43:25

Hi @LuckBringer,

Sorry for the delay on this one.

In the class that implement OnRoomListUpdate make sure to call base methods if you override OnEnable or OnDisable.

if you have a class that extends MonoBehaviourPunCallbacks and implement OnEnable or OnDisable methods you must override them and call base methods:

As I can see SupportLogger.OnRoomListUpdate was called successfully so OnRoomListUpdate that you implemented is not called probably because of an issue in your code or your project. I'm sure it's something silly and tiny that you overlooked.

Also check that the component implementing it is enabled and attached to an active GameObject.

LuckBringer
2021-02-11 18:37:51

Hi John!

Thanks for your reply again, I really have no idea what's going on.

So the gameobject with the script is active, and you can see the setup through the link below:
https://imgur.com/zZ1AcDm

And this is the script with the code:
https://imgur.com/a/FxNh8Wp

As you can see, the second instance can recognize that there is a room, and even through they are on the same region, the OnRoomListUpdate method cannot find the room.

What should I try next?

Many thanks again, John
Gabriel.

JohnTube
2021-02-11 20:53:42

Hi @LuckBringer,

I want to re emphasize that SupportLogger.OnRoomListUpdate was called here (in a screenshot of the second client logs from a previous post).
So from our point of view, everything works fine.

What should I try next?

  • Check if you don't implement more than one OnRoomListUpdate in your scene and maybe one of them throws an unhandled exception that prevents further calls to the other remaining OnRoomListUpdate methods not called yet.

If an unhandled (uncaught) exception occurs in one of the implemented interfaces' callbacks' methods, all other implemented ones for the same interface, same signature and not already called, won't be called. This is due to the fact that we call the implemented interface callback methods of the same signature in a loop in the order of their registration (which could be random in Unity if you register in MonoBehaviour methods).

source

  • OnRoomListUpdate callback is a result of receiving one of two events: GameList (initial rooms list when joined to the lobby) or GameListUpdate (future updates to the initial list). This is handled inside LoadBalancingClient.OnEvent (Assets\Photon\PhotonRealtime\Code\LoadBalancingClient.cs) as you can see below:

what you could do:

  • add logs there to see event is received
  • implement custom IOnEventCallback.OnEvent or LoadBalancingClient.EventReceived (PhotonNetworjk.NetworkingClient.EventReceived) event handled and check when/if client receives EventCode.GameList or EventCode.GameListUpdate.
  • attach Visual Studio Debugger to Unity and start debugging this.

Tobias
2021-02-16 14:27:31

It seems you are running a Unity alpha version (which is quite dated).
Just for the fun of it, I would run the project in 2019.4.x in case.

Let us know how Hamza's latest suggestions worked.
You mailed us but I don't get what the latest status is...

LuckBringer
2021-02-16 15:27:02

Hi John and Tobias!

Once again, thanks for your reply!

I checked and I only have one OnRoomListUpdate in my scene.

And I couldn't quite understand this part:

"- add logs there to see event is received

  • implement custom IOnEventCallback.OnEvent or LoadBalancingClient.EventReceived (PhotonNetworjk.NetworkingClient.EventReceived) event handled and check when/if client receives EventCode.GameList or EventCode.GameListUpdate.
  • attach Visual Studio Debugger to Unity and start debugging this. "

But I did add debugs here:
https://imgur.com/a/TU7Q7H9

And in the game it appeared this:
https://imgur.com/a/IImT372

And you also asked me in the email to test the Asteroid example, it also didn't work. No rooms were listed there.

And I can't use a newer version of Unity unfortunately, because I use SteamVR and it doesn't work for never Unity versions.

Regarding the lobby, I'm not doing anything to it I believe:
https://imgur.com/a/TjfnomS

When I create a room I use this:
PhotonNetwork.CreateRoom("Room "+ roomListCount + 1 + ": Player level " + playerDataScript.level, options, TypedLobby.Default);

In the email, you mentioned this: "Check if the MonoBehaviourPunCallbacks.OnEnable() is being called", how do I do that?

(The players can connect to each other if they use JoinRandomRoom, not sure if this information helps)

Once again, thanks for the help! This one is a tricky one!
Gabriel.

Tobias
2021-02-17 10:26:03

you mentioned this: "Check if the MonoBehaviourPunCallbacks.OnEnable() is being called", how do I do that?

As you did with the "After switch". Just add a debug line and make sure it shows. You need to make sure that your class for callbacks is actually registered to get those!

By the way: As the "After switch" shows up, this means the client get the list of rooms just fine. For some reason, your behaviour does not get the callback. One more reason to make sure it's registered correctly for getting callbacks.

LuckBringer
2021-02-18 02:02:28

Hi Tobias!

Thanks for the reply once again.

Apologies, but I still don't understand "Check if the MonoBehaviourPunCallbacks.OnEnable() is being called", I tried searching on my project for a function called "MonoBehaviourPunCallbacks.OnEnable()", but found nothing, and researching on google doesn't show what this is it.

Do you mean I have to add a debug on OnEnable of my RoomListingsMenu script to see if it is running? I did add a debug on void Start and it shows that it's being called:
https://imgur.com/a/kzLMPuN

Warmest regards,
Gabriel.

LuckBringer
2021-02-21 00:07:21

Hey guys, it seems it's working.

If I test with 2 different instances on the same computer, I can connect both instances with each other and play, however if I try to list the rooms, it doesn't work. But if it's on a instance from another computer, then the room will be listed.

It's very strange that I was able to connect 2 instances on the same computer, but not list the room, it seems the issues has been resolved!

Many thanks for the help Tobias and Hazem!
Gabriel.

JohnTube
2021-02-22 10:44:37

Thanks for the updated.
Strange issue indeed.
Maybe it's a timing issue: OnRoomListUpdate callbacks are triggered before the script is enabled (and callbacks class registered for that component).

LuckBringer
2021-02-22 15:35:48

Really strange indeed.

At the end the solution was this, if everything else is working but the RoomList, test the second instance with another computer and if possible using another internet connection.

Tobias
2021-02-24 12:46:20

It should really not be that complicated. For me, it works without the effort.
Maybe you give another Unity version a try?
You could also check if the "Asteroids Demo" from the PUN 2 package behaves alike.

LuckBringer
2022-04-19 17:37:15

For anyone having the same issue, I did not find a solution, however I just used the Asteroid Demo and modified it to my needs, it's easier.

Back to top