Temporary loss of connection

capitalj
capitalj ✭✭
What is the best way to handle a temporary loss of connection, ie if a players internet connection drops (wifi, etc..) for a few seconds I would like to put up a message to all players in the match, pause the game and attempt to reconnect that player (it's not a real-time game so it's okay to pause). But I've found that it takes a long time, 20+ seconds, for all clients to get a photon notification that a player has disconnected. Any specific way to handle this? or an event that I can subscribe to that will let me know as soon as a player has disconnected from a match/room?

-JJ

Comments

  • You can take a look at Analyzing Disconnects, which gives some tips on disconnect handling.
  • Thanks for the article link. I read it over and it doesn't seem to offer any advice that refers to how to handle the situation I described. The problem is not that I am getting many disconnects, the problem is that I don't get a disconnect event firing until 20+ seconds after the disconnect actually happens. So the clients don't know that they have been disconnected.
  • There is no known issue that causes such long delays, so we have to take a look at what you do actually.
    In worst case, a timeout is done after 10 seconds. In most cases, it's much earlier.

    Could you please test one of the Demos that are in the PUN package in the same way as you test your game now?
    As example: The boxes demo will immediately destroy the boxes of leaving players. If they leave or disconnect, the destroy is done quickly. If they leave without telling the server they are off, then the timeout will be ~10 seconds and can't be much faster (we need some time to decide if a client is temporarily not responding or if it's gone for good).

    These are the disconnect/leave related callbacks:
    Implement OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer) { ... } and it gets called when another player leaves the room you are in.
    Implement OnLeftRoom(){ ... } and PUN calls it when "this" client leaves.
    Implement OnDisconnectedFromPhoton(){ ... } and PUN calls it when the client did get disconnected.

    Let me know which platform you test on and which Unity and PUN versions you use and what you found with our demos.