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

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.

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.

PUN Callbacks are sometimes not calling back.

2021-07-02 01:02:30

I'm using the cloud server for a multiple player project I'm working on and I notice that my Unity client will sometimes not receive PUN callbacks.

I'll post the code I'm using below. It's all consolidated to a single class.

So my Photon connection delegation works like this: At Start I connect automatically. I get On Connected To Master callback then I attempt to Join Random Room. On Random Room Join Failed, I then attempts to create a room assuming that one doesn't exist. Create Room then gets called, makes the room, but then I get no more callbacks. No OnCreatedRoom. No On Joined Room. Nothing else happens.

This is an intermittent thing where callbacks just stop and I'm not sure how to detect a could service error I get no feedback on.

This multiplayer setup is very simple. I'm not taking advantage of matchmaking, or hosting multiple rooms or lobbies. I'm just trying to get a shared scene online that my clients connect to automatically where Unity Game Object movement is synchronized across multiple AR devices.


2021-07-02 02:11:50

I'm having a very similar issue where sometimes when I create a room, there's no callback at all, and this is because the room is never joined to begin with.

No OnJoinedRoomFailed gets called either. It just times out and disconnects.

I've been going crazy over this for days now.

2021-07-02 10:30:30

If there is a timeout, this may in fact cause the other callbacks to never fire. It's not a "could not join a room" problem when the connection is gone...
This page about Analyzing Disconnects may help figure out what's up.

@SteelWindows, is there a disconnect callback in your case?
If this reproduces, please enable the SupportLogger and (in best case) run Wireshark along with the repro attempts. Send the full log and capture to: [email protected] please. We'd like to take a look.

In general: The most common cause to not get callbacks is that objects that should register for callbacks, don't register in the first place or get destroyed.
Which region do you connect to?

Edit: Update PUN 2 to the latest version, if you didn't yet. Let us know the platform you build for.

2021-07-02 15:01:38

So far I have not been able to reproduce it today. I did some thorough regression tests connecting and disconnecting through API calls looking for an OnRoomJoined callback that doesn't make it. But so far I have 100% success out of 100 trials.

I'm guessing last night's oddness was a fluke with the cloud server. Maybe a packet over the greater internet was lost or something strange. I'm expecting to see it again in the next few days because that seem to be it's rate of reoccurrence. It seems to happen when it happens and getting it to reproduce through stress testing doesn't make it happen.

2021-07-06 10:40:18

Hi @SteelWindows,

Thank you for choosing Photon!

There are some small mistake in the code:

  • First, when you extend MonoBehaviourPunCallbacks no need to implement IInRoomCallbacks interface as MonoBehaviourPunCallbacks already does that.
  • Second, when you extend MonoBehaviourPunCallbacks and override OnEnable and OnDisable and call respective base class methods no need to call AddCallbackTarget or RemoveCallbackTarget respectively. This may cause the callbacks to be registered and called twice?!

So: I would get rid of IInRoomCallbacks, OnEnable and OnDisable.

I did not read all the thread and all details but this could be related maybe?

Back to top