Frequent disconnects and Rejoin

For our last two games we received frequents disconnects with either Client or Server timeouts. After investigating and analysing this for a while it appears that this happens whenever the devices switches the WIFI networks or switches between cellular and WIFI.

In order to workaround this we now tried to implement rejoin of players while still in the game (in the game scene).

Whenever the device switches the network we get an error when PUN tries to send its packages. After 10 second the client disconnects with ClientTimeout. At this point we call ReconnectAndJoin, the rooms PlayerTtl is set to 30 seconds. The second player is still in the game at this point. (and waiting until he received data from the other player again).

When we now call ReconnectAndJoin it appears to work fine basically. PUN connects to the server and joins the room again. But PUN destroys our player game object (we instantiate the player object when the game started with PhotonNetwork.Instantiate). Additionally, it appears that PUN tries to instantiate the object twice and also executes all RPCs sent via server buffered earlier.

What I hopped for is that a rejoin just "reuses" the already created game objects for this player, like, as the player never left. From what it looks like it just joins the player again, creates all instantiated objects again and then destroyes the old owned objects. Almost like a new player joined.

What is the intended way of usage for rejoin? Is it possible to just rejoin the player and continue without creating new game objects?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited November 2017
    Hi @robertsze,

    Thank you for choosing Photon!

    What is the intended way of usage for rejoin?
    A rejoin feature is meant to reuse the same actor inside the room based on its userId (preserve its properties, interest groups and cached events).

    Is it possible to just rejoin the player and continue without creating new game objects?
    Unfortunately this is not possible out-of-the-box. We may update behaviour in the future either in PUN itself (client code) to skip some received cached events on rejoin OR on server side to skip (re)sending some cached events to rejoining actor. But this is not decided yet and it will take a while. If this is very important for you, you may start looking into the code to skip "some" events when rejoined, for instance, events where sender actor number is equal to the actor number of the local player.
  • Hi John,

    Hmm, so how should one handle this situation? Lets say we have a sports/golf game. In the middle of the game the device of player A switched from WLAN to 3G (which happens a lot), and photon just disconnects. You mean, although the physical connection is available immediately again, there is no way to reconnect to the running game without destroying all player owned objects, recreating them and adding tons of code to replicate the state the game had before the disconnect? Please note, this is a 1vs1 game, the game starts, when both players joined a room. This is a complete different design than lets say a first person multiplayer shooter where player can join and leave whenever they want.

    The strange thing for me is, when player A disconnects because of a network issue, the player A is still alive on players B device with the actor state set to "inactive", which is actually what we won't. When player A rejoins, the state gets to active again on players B device, but it complete reinitializes on players A device.

    There is no way to handle this now?
  • Btw, we receive around 6k such disconnects per day for around 70k DAU, so this is an huge issue for us. (All disconnects have a high ResentReliableCommands counter) and we can reproduce this easily by just switching from Wifi to cellular or switching in the unity editor from Wifi to ethernet while the game is running.)
    Worse, the user bets virtual currency for each match and such a disconnect make them loose immediately. (its fine if a background disconnect or similar user "triggered" disconnects lead to this result, but not if the device changes internet connectivity by switching wifi<->cellular)

    So basically we are looking for a solution to either just "reconnect the socket" when the network interfaces changed or any other way to reconnect while in the middle of a game. (Games itself last for no longer than 2 minutes)
  • Let's continue this topic via ticket / mail, as you opened that path as well.
  • JohnTube wrote: »
    Hi @robertsze,

    Thank you for choosing Photon!

    (Quote)
    A rejoin feature is meant to reuse the same actor inside the room based on its userId (preserve its properties, interest groups and cached events).

    (Quote)
    Unfortunately this is not possible out-of-the-box. We may update behaviour in the future either in PUN itself (client code) to skip some received cached events on rejoin OR on server side to skip (re)sending some cached events to rejoining actor. But this is not decided yet and it will take a while. If this is very important for you, you may start looking into the code to skip "some" events when rejoined, for instance, events where sender actor number is equal to the actor number of the local player.

    So was this every implemented or not? I'm currently struggling with this same issue, 2 years later.
    I made a new forum post about it here: https://forum.photonengine.com/discussion/15900/resetting-a-photonview-id-without-destroying-it
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @JD1337,

    Thank you for choosing Photon!

    We did not change things regarding this.
    You will need to handle this yourself or change PUN code if necessary or find a workaround.