Problem with ReconnectAndRejoin

Options
Hello,
I have a problem with ReconnectAndRejoin
1/ I lost internet connection
2/ 10 secondes later I launch ReconnectAndRejoin ()
3/ I am still disconnected, so 5 seconds later I have a time out and all my photonView instantiated are destroyed (why not ..)
4/ 10 secondes later I retry to connect with ReconnectAndRejoin ()
5/ I'm now connected to internet, so I rejoined the room with success and surprise, I'm waiting for photon recreate all my photonView destroyed but nothing happen.

I configured playerTtl to -1
and EmptyRoomTtl to 60 000

Could someone help me please ?

Comments

  • Djebedia
    Options
    Hi
    Try to set playerTtl to something greater than zero and try to reconnect before that time expired.
    Also, try to set PhotonNetwork.autoCleanUpPlayerObjects to false so that Photon won't destroy player objects
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2019
    Options
    Hi @alexandre,

    Thank you for choosing Photon!

    I think you may be calling ReconnectAndRejoin too soon or too late.
    ReconnectAndRejoin needs to be called when disconnected unexpectedly i.e. only after OnDisconnected callback is triggered.
    If you are using PUN2 checkout this DisconnectsRecovery UtilityScript from here.

    @Djebedia

    Actually setting PlayerTTL to -1 means the actor can rejoin and without time limits.
    So there is no issue on this side.
    PhotonNetwork.autoCleanUpPlayerObjects is from PUN1 and is deleted in PUN2. In PUN2 you can change this behaviour using RoomOptions.CleanupCacheOnLeave. But it depends on the behaviour expected/wanted.
  • alexandre
    Options
    Thank you for your answers.
    @JohnTube,
    I try to call ReconnectAndRejoin immediatly after disconnecting call back
    I have these logs after losing connexion ::
    OnStatusChanged: TimeoutDisconnect current State: Joined
    Can't execute Disconnect() while not connected. Nothing changed. State: Joined
    OnStatusChanged: Disconnect current State: Joined
    OnDisconnectedFromPhoton() was called by PUN
    ReconnectAndRejoin()
    10 seconds later ::
    OnStatusChanged: TimeoutDisconnect current State: ConnectingToGameserver
    Can't execute Disconnect() while not connected. Nothing changed. State: ConnectingToGameserver
    OnStatusChanged: Disconnect current State: ConnectingToGameserver
    Network destroy Instantiated GO: etc etc
    Network destroy Instantiated GO: etc etc

    OnDisconnectedFromPhoton() was called by PUN

    I'm not using PUN2

    Thank you for your help
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @alexandre,

    I still can't figure this out clearly.

    It seems the internet connection could be bad or have intermittent issues.
    Maybe when you call ReconnectAndRejoin the client also fails to do so due to same internet problems.

    Or are you testing this on purpose?
    I mean are you disconnecting from internet manually/explicitly or simulating bad internet connection?

    When ReconnectAndRejoin is called, is the internet back?

    What PUN Classic version are you using? latest? if not, please update.

    For the logs you provided, the stack trace is missing which could be useful.

    Could you provide clear minimal 100% reproduction steps?
  • alexandre
    Options
    Yes I'm disconnecting manually for test with unity editor to simulate an internet disconnection.
    When ReconnectAndRejoin is called, internet is not back but I want to retry ReconnectAndRejoin in a loop to reconnect automaticaly when internet will be back.
    According to changelog, i'm using v1.95 (18. March 2019)

    Do you want I send you stack trace in a txt file by mail ?

    Thank you

  • alexandre
    alexandre
    edited May 2019
    Options
    Hello JohnTube,
    Please to find logs of destroy intanstiated object ::
    Network destroy Instantiated GO: myObject
    UnityEngine.Debug:Log(Object)
    NetworkingPeer:RemoveInstantiatedGO(GameObject, Boolean) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3518)
    NetworkingPeer:LocalCleanupAnythingInstantiated(Boolean) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1218)
    NetworkingPeer:LeftRoomCleanup() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1183)
    NetworkingPeer:OnStatusChanged(StatusCode) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2191)
    ExitGames.Client.Photon.<>c__DisplayClass102_0:b__0()
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:161)


    After debugging the code, I found the reason :
    Function
    LeftRoomCleanup()
    {
            bool autoCleanupSettingOfRoom = (this.CurrentRoom != null) ? this.CurrentRoom.AutoCleanUp : PhotonNetwork.autoCleanUpPlayerObjects;</i>
    The CurrentRoom is null because I have lost the connexion, so PhotonNetwork.autoCleanUpPlayerObjects variable is used, and PhotonNetwork.autoCleanUpPlayerObjects is set to true and I can't change it.

    Please to help.

    Thank you

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @alexandre,

    PhotonNetwork.autoCleanUpPlayerObjects is set to true and I can't change it.
    Why? What do you mean you cant?

    As @Djebedia mentioned before, it's possible PhotonNetwork.autoCleanUpPlayerObjects = false;.
  • alexandre
    Options
    Hi @JohnTube,

    I don't know why, it's just set like that in PUN code.
    When I'm trying, I have error below

    Setting autoCleanUpPlayerObjects while in a room is not supported.
    UnityEngine.Debug:LogError(Object)
    PhotonNetwork:set_autoCleanUpPlayerObjects(Boolean) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:569)
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @alexandre,

    Set it before entering the room.
    e.g. inside OnConnectedToMaster or in Start of a MonoBehaviour etc.
  • alexandre
    Options
    Ok it was the solution.

    Thanks a lot for your help.