Question in TimeoutDisconnect

xzlxt720
xzlxt720 ✭✭
edited December 2011 in Photon Server
I have download the RC7, I start 1000 clients(do nothing just connet) 1000 threads connect to my server, all the clients connect successs but a few time later, most of the clients receive the statuscode TimeoutDisconnect or Disconnect.
I do not know what went wrong.

Comments

  • Your computer likely is overloaded with the load and loses connection thus they receive the timeout.
    If you have photon on the same machine then it will do so for pretty surely with 1001 entities trying to hammer the same port etc.

    Also are you on the free license? cause then the limit is 100 CCU, all others would get disconnect anyway
  • Hi,dreamora
    I have the client and server on the same machine and use the trial license (unlimited CCU, 30 day limit).
    I startup a console application, created a 500 connection, use a thread per connection.After several minutes, the console application went crash, the debug messages are as follows.


    and there are no such file path 'C:\dev\dotNet-sdks-split\...' on my computer.
  • yeah the path error there likely comes from the fact that you used this app to test it and didn't build your own that you started locally on your machine / a remote debugger reachable place. otherwise it would present you a real thing.
    Though even then this source is not accessable like that.

    Can't say much on where it comes from beside the fact that it comes from connecting and normally does not happen on 'time out upon connection' (for example when the firewall blocks ya).
  • Perhaps my app code was wrong, please help look at my code.
    using System;
    using System.Threading;
    using System.Configuration;
    using ExitGames.Client.Photon;
    using System.Collections.Generic;
    
    namespace clienttest
    {
        public class Client : IPhotonPeerListener
        {
            private string m_serverAddress;
    
            private string m_serverPort;
    
            private string m_applicationName;
    
            private string m_user;
    
            private int m_number;
    
            private PhotonPeer m_peer;
    
            public Client(string serverAddress, string serverPort, string applicationName, string user,int number)
            {
                m_serverAddress = serverAddress;
                m_serverPort = serverPort;
                m_applicationName = applicationName;
                m_user = user;
                m_number = number;
            }
    
            public void Start(object obj)
            {
                //Console.WriteLine("num:{0} is Start", m_number);
                m_peer = new PhotonPeer(this);
                try
                {
                    if (m_peer.Connect(string.Format("{0}:{1}", m_serverAddress, m_serverPort), m_applicationName))
                    {
                        //Console.WriteLine("num:{0} is listening from server", m_number);
                        do
                        {
                            //  Console.WriteLine(".");
                            m_peer.Service();
                            System.Threading.Thread.Sleep(50);
                        }
                        while (true);
                    }
                    else
                    {
                        Console.WriteLine("Connect failed!");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Connect error: " + e);
                }
            }
    
            #region IPhotonPeerListener Members
    
            public void DebugReturn(DebugLevel level, string message)
            {
                Console.WriteLine("DebugReturn:" + message);
            }
    
            public void OnEvent(EventData eventData)
            {
                Console.WriteLine("OnEvent");
            }
    
            public void OnOperationResponse(OperationResponse operationResponse)
            {
                Console.WriteLine("OnOperationResponse");
            }
    
            public void OnStatusChanged(StatusCode statusCode)
            {
                switch (statusCode)
                {
                    case StatusCode.Connect:
                        DoSomething();
                        break;
                    case StatusCode.DisconnectByServer:
                    case StatusCode.DisconnectByServerLogic:
                    case StatusCode.DisconnectByServerUserLimit:
                    case StatusCode.Disconnect:
                    case StatusCode.TimeoutDisconnect:
                    default:
                        Console.WriteLine("Num:{0} == stautsCode ==>{1} ", m_number, statusCode);
                        break;
                }
            }
    
            public void DoSomething()
            {  
                Console.WriteLine(m_user+"=>Connect OK.");
            }
    
            #endregion
        }
    
        class Program
        {
            static void Main(string[] args)
            {
               string serverAddress =  ConfigurationManager.AppSettings["ServerAddress"];
               string serverPort = ConfigurationManager.AppSettings["ServerPort"];
               int  clientNum = Convert.ToInt32(ConfigurationManager.AppSettings["ClientNum"]);
               string applicationName = ConfigurationManager.AppSettings["ApplicationName"];
               string user = ConfigurationManager.AppSettings["User"];
               ThreadPool.SetMinThreads(clientNum, clientNum);
               for (int i = 0; i < clientNum; i++)
               {
                   string username = string.Format("{0}_{1}", user, i);
                   Client client = new Client(serverAddress, serverPort, applicationName, username, i);
                   Thread.Sleep(100);
                   //ParameterizedThreadStart start = new ParameterizedThreadStart(client.Start);
                   //Thread thread = new Thread(start);
                   //thread.Start();
                   //client.Start(null);
                   ThreadPool.QueueUserWorkItem(client.Start, null);
               }
               Console.ReadKey();
            }
        }
    }
    
  • If there is something wrong then its beyond my capability to see it, as such I would assume its a network congestion: you overflood the server network wise or at worst the DoS protection on the network hardware in front of it and they just 'cut' the line. (thats what happens in standard unity networking if you use RPC which aren't batched and ignore send rate - with that you can disconnect whole win2k8 servers from the network ...)