DisconnectByServerLogic Disconnect peer by auth timeout

I create a Peer on my unity Client
void Start()
    {
        Debug.Log("Start Connect");
        peer = new PhotonPeer(this, ConnectionProtocol.Udp);
        peer.Connect("127.0.0.1: 27001", "Master");//Post number used 5505 also disconnect
        connected = false;
    }

    // Update is called once per frame
    void Update()
    {
        peer.Service();
    }

 public void OnStatusChanged(StatusCode statusCode)
    {
        Debug.Log("serStatus-----" + statusCode.ToString());

        switch (statusCode)
        {
            case StatusCode.Connect:
                break;
            default:
                peer.Connect("127.0.0.1: 27001", "Master");//connect when disconnect
                break;
        }
    }
    }

Every 10 seconds will recive statusCode "DisconnectByServerLogic"
And see the photon sever log is
DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer - Disconnect peer by auth timeout. timeout:20000, p:T:MasterClientPeer,ConnId:0,ip:127.0.0.1:62900,Udp,GpBinaryV16
 DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer - Disconnect: peer=T:MasterClientPeer,ConnId:0,ip:127.0.0.1:62900,Udp,GpBinaryV16, UserId:: reason=2, detail=
DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer - Auth Timeout Checker stopped. authTimeout:20000 p:T:MasterClientPeer,ConnId:0,ip:10.127.0.0.1:62900,Udp,GpBinaryV16
I dont want receive disconnect code so please help me ! Thanks!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Tree,

    Thank you for choosing Photon!

    Why not use PUN or Photon Unity SDK?
    Why do you need to make your own client from scratch?
  • hi, @Tree

    you have to send Authenticate request with corresponding parameters otherwise server disconnects you. that is expected and correct behavior.

    our .netclient sdk contains LoadBalancingPeer it may help you with doing standard work if you connect to LoadBalancing

    best,
    ilya
  • @chvetsov
    Thank you so much.Now I use LoadBalancingPeer to send operation,but I send another error
    Got DisconnectMessage. Code: -37 Msg: "OpCode_163 is blocked". Debug Info: {}
    How to slove the error?Thanks!
  • @chvetsov
    this is my code about the error
     public const byte LastHitBattleReady = 163;
    SendOperation(OperationCode.LastHitBattleReady, data, SendOptions.SendReliable);
    
  • hi, @Tree

    LoadBalancing/Realtime uses predefined set of operations. everything else is blocked. Use RaiseEvent operation to send signals about everything in your game. It is flexible enough to fit to any needs.
    if logic of your game more or less fits to Realtime, I would recommend to use plugin. This will reduce amount of things you have to know and you will be able to add protection from hackers and cheaters

    if you still need your own event code, than take a look into `void InitInboundController()`. it defines the range of allowed operations

    best,
    ilya
  • @chvetsov I got it. Thank you so much!
  • @chvetsov
    I meet another question. when I send event from Sever
    this code in GameApplication.cs
    protected virtual PeerBase CreateGamePeer(InitRequest initRequest)
            {
                var peer = new GameClientPeer(initRequest, this);
                {
                    if (this.webRpcManager.IsRpcEnabled)
                    {
                        peer.WebRpcHandler = this.webRpcManager.GetWebRpcHandler();
                    }
                    initRequest.ResponseObject = "ResponseObject";
                }
    
    
                PeerList.Add(peer);//the line add by mine
                return peer;
            }
    
    this code is my send
    public static void SendEvent(Photon.Hive.Operations.OperationCode code)
            {
                EventData ed = new EventData((byte)code);
    
                foreach (PeerBase peer in PeerList)
                {
                    peer.SendEvent(ed, new SendParameters());
                }
            }
    
    in my unity client I recive twice event
    this is log stack
    UnityEngine.Debug:Log(Object)
    LastHitBattle_PhotonManager:OnEvent(EventData) (at Assets/Scripts/PhotonControl/LastHitBattle/LastHitBattle_PhotonManager.cs:45)
    PhotonListenerManager:OnEvent(EventData) (at Assets/Photon/PhotonRealtime/Code/PhotonListenerManager.cs:47)
    Photon.Realtime.LoadBalancingClient:OnEvent(EventData) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3364)
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:898)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:563)
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1863)
    Photon.Voice.Unity.VoiceConnection:Dispatch() (at Assets/Photon/PhotonVoice/Code/VoiceConnection.cs:548)
    Photon.Voice.Unity.VoiceConnection:FixedUpdate() (at Assets/Photon/PhotonVoice/Code/VoiceConnection.cs:531)
    
    UnityEngine.Debug:Log(Object)
    LastHitBattle_PhotonManager:OnEvent(EventData) (at Assets/Scripts/PhotonControl/LastHitBattle/LastHitBattle_PhotonManager.cs:45)
    PhotonListenerManager:OnEvent(EventData) (at Assets/Photon/PhotonRealtime/Code/PhotonListenerManager.cs:47)
    Photon.Realtime.LoadBalancingClient:OnEvent(EventData) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:3364)
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:898)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:563)
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1863)
    Photon.Pun.PhotonHandler:Dispatch() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:221)
    Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:147)
    
    I used pun2 and photon voice in my project.I just want add pun2 peer in my server peerlist.I hope just recive once event in my unity. Can I know who they are about pun2 or voice in Photon Server?
    Thanks!
  • hi, @Tree
    you do not have to return "ResponseObject" if you do not need too

    the way you send event repeats inefficiently what we already have.
    I would recommend to read documentation our site and take a look on samples

    best,
    ilya