Photon Disconnection Problem

Options
Hello, I have a card game which is on markets. I m using Photon Network. This is a realtime multiplayer game which has 4 players in the game. The game is all managed by master player. If slave player disconnects, there is no problem just that player disconnect, but if master player disconnects, game stops. i add this scenario inside "OnPhotonPlayerDisconnected" function, but the problem is, sometimes (often) any player, master or slave disconnects with no reason while playing. I couldnt understand why this happens. Do you have an idea?
Thanks

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @bbekec,

    Thank you for choosing Photon!

    Read about "Master Client and Host Migration" and "Analyzing Disconnects".
  • bbekec
    Options
    Thank you, I will check it.
  • bbekec
    Options
    Hello, I still having disconnection problem .
    In my own tests with Android, I cannot catch any disconnection, but the game has a lot of players and players complain about disconnection. I cannot test much more for IOS but I can understand that complains generally come from Android. Some comment on Playstore and some directly mails me.
    There is a disconnection type. While playing if there is a change from Wifi to Mobile internet or Mobile internet to Wifi disconnection occurs. It lets me think that there is an undetectable (by me) weak signal causes disconnection even if there is no change from mobile to wifi. Is it possible? If yes, Is there any option to ignore small weak signals (Filter)?
    Problem also can be caused by another reason. Any help please.
    Thanks.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2020
    Options
    Hi @bbekec,

    Do you use best region or fixed region?
    maybe if you're using a fixed region, some customers have a bad RTT.

    Your options:

    - tweak client settings as shown in the doc (QuickResends, etc.)
    - increase log level or add log messages and one of the users/customers who can reproduce gets you the logs
    - implement anonymous stats/logs telemetry agent in your app with users' consent to get all info you need from a central dashboard
    - implement a good reconnect mechanism to recover from unexpected disconnects: make use of PlayerTTL and ReconnectAndRejoin (quick rejoin).
  • bbekec
    Options
    Hello,
    This is my settings,
    Untitled-1.jpg
    and this is my connection Script To Photon,
    public void FBBagliPhoton()
    {
    if (GameObject.Find("DurumText")) GameObject.Find("DurumText").GetComponent<Text>().text = SelectLanguage.Instance.photonBaglaniyor;
    PhotonNetwork.ConnectUsingSettings(PhotonGameVersion);
    PhotonNetwork.AuthValues = new AuthenticationValues();
    PhotonNetwork.AuthValues.AuthType = CustomAuthenticationType.Facebook;
    if (FB.IsLoggedIn)
    {
    if (!string.IsNullOrEmpty(AccessToken.CurrentAccessToken.UserId))
    PhotonNetwork.AuthValues.UserId = AccessToken.CurrentAccessToken.UserId; // alternatively set by server
    if (!string.IsNullOrEmpty(AccessToken.CurrentAccessToken.TokenString))
    PhotonNetwork.AuthValues.AddAuthParameter("token", AccessToken.CurrentAccessToken.TokenString);
    }
    }
    private void OnConnectedToMaster()
    {
    PhotonNetwork.player.NickName = playerNameFB;
    PhotonNetwork.JoinLobby(TypedLobby.Default);
    if (PhotonNetwork.connectedAndReady)
    {
    if (GameObject.Find("DurumText")) GameObject.Find("DurumText").GetComponent<Text>().text = SelectLanguage.Instance.photonBaglandi;
    if (GameObject.Find("KullaniciIsimTextText")) GameObject.Find("KullaniciIsimTextText").GetComponent<Text>().text = playerNameFB;
    PlayFabBaglan();
    }
    else { if (PhotonNetwork.connected) PhotonNetwork.Disconnect(); }
    }

    And I use GelenDataIsleyici.cs File to provide data transfer betveen clients and master
    public class GelenDataIsleyiciPhotonBt : MonoBehaviour
    {
    public PhotonView pv;

    // This is general data transfer code to send to other clients and master
    // More than 100 calls for this function
    public void sendData(string command, string command2)
    {
    string sendingData = command + ":" + command2;
    pv.RPC("gelenDataIsle", PhotonTargets.Others, sendingData);
    }
    // This is getting all datas from other client and master
    public void gelenDataIsle(string dataGelen)
    {
    string[] rawString = dataGelen.Split(':');

    if(rawString[0] == "Ping") // for all first strings I created a method.
    {
    ...
    ...
    }
    if(rawString[0] == "PingDonus")
    {
    ....
    ....
    }
    }
    }

    Here is other method which controls JoinRoom and Disconnection

    void OnJoinedRoom()
    {
    ....
    }

    public void OnPhotonPlayerDisconnected(PhotonPlayer player)
    {
    .....
    }

  • bbekec
    Options
    "Do you use best region or fixed region?
    maybe if you're using a fixed region, some customers have a bad RTT."
    There is no option for this in Photon Settings. Just i see is region starts with "EU" and ends with "None". There is no Best Region Option or Fixed Region Option.
  • bbekec
    Options
    Hello, I am still having disconnection problem and i successfully get the reason of disconnection. It is "ServerTimeout". I looked at "Analyzing Disconnects" but there is no specific solution.
    I started thinking about my datas which are sent by RPC. I m generally sending datas as strings. Should i convert them to byte or something else before sending? And then convert them again to string in receiver side.
    please help me!!
    Thanks
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @bbekec,

    Sending strings as RPC should not be a problem unless you are sending too often or a too big/long strings.
    And it also depends on how many players are sending.
    Are those RPCs buffered?

    Does the disconnection happen just after joining the room or later?

    Maybe the devices that the "ServerTimeout" are low-end ones and do not have high specs.
    Limited hardware can impact performance so clients take more to process incoming data and reply to the server to send ACKs to keep the connection alive.

    So maybe you need to optimize your code by profiling your application and seeing if there are not too many FPS drops and that the client is responding properly and not becoming too slow to act normally.
  • bbekec
    Options
    Hello John, Thanks for your help.
    "Are those RPCs buffered?" I didnt do anything to buffer.
    The code is below
    public void sendData(string command, string cardName)
    {
    string sendingData = command + ":" + cardName;
    byte[] serializedData = Encoding.ASCII.GetBytes(sendingData);
    pv.RPC("gelenDataIsle", RpcTarget.Others, serializedData);
    }

    public void gelenDataIsle(byte[] dataGelen)
    {

    string byteGelenToString = Encoding.ASCII.GetString(dataGelen);
    string[] rawString = byteGelenToString.Split(':');
    if(rawString[0]== "Something")
    {
    }
    }


    "Does the disconnection happen just after joining the room or later?, It happens while playing suddenly.

    "So maybe you need to optimize your code by profiling your application and seeing if there are not too many FPS drops and that the client is responding properly and not becoming too slow to act normally.", Maybe this is the reason i am not sure. I will try to raise the performance of the game. Do you have some suggestion for me to increase performance of the game? To avoid ACK's to be late.
    Regards
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Do you have some suggestion for me to increase performance of the game?
    Nothing special no. Just profile your game and check FPS and Photon traffic stats.