How can have more than 8 players connected to my server
Hello everyone !
I have a private server with public ip and i'm making some uNet tests. So I can connect to this server with no problems thanks to NetworkManager.StartServer() and NetworkManager.StartClient() methods.
But, when I have 8 players on the server, I can't connect the nineth. I set 100 to the NetworkManager.maximumConnection, so i don't really understand why this happen...
In my Unity Service Mulyplayer account, i create a new project and set to 100 the CCU in a session too
Here is my code, I hope someone help ! :)
 using UnityEngine;
 using UnityEngine.Networking;
 using UnityEngine.Networking.Match;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.Networking.Match;
 
 public class ServerConnection : NetworkManager
 {
     [Header("!!!!! Set it true to build the server !!!!!")]
     public bool serverMode = false; // Is it the server build ? (Auto launch server if true)
     [Space(20)]
     public Vector2 logWindowSize = new Vector2(300, 150); // Size of the log window
 
     private NetworkClient myself; // My own client connection
     private List<string> allLogs = new List<string>(); // All logs in the window
     private Vector2 logScrollBar = Vector2.zero; // scrollbar in the log window
 
     void Start()
     {
         AddLogs("Not Connected");
         if (serverMode)
         {
             maxConnections = 100;
             StartServer();
             return;
         }
     }
 
     /// <summary>
     /// Launch a connection
     /// </summary>
     void OnClickConnect()
     {
         myself = StartClient();
         StopCoroutine("TestConnectionTimeout");
         StartCoroutine("TestConnectionTimeout");
     }
 
     void OnGUI()
     {
         // Server connection
         if (myself == null || (myself != null && !myself.isConnected))
         {
             GUILayout.BeginHorizontal();
             if (GUILayout.Button("Connection Reseau Local") )// <= When i connect using my pc as a server
             {
                 networkAddress = "127.0.0.1";
                 OnClickConnect();
             }
 
             if (GUILayout.Button("Serveur Local")) // <= When i connect to the server from server network
             {
                 networkAddress = "192.168.1.33";
                 OnClickConnect();
             }
 
             if (GUILayout.Button("Serveur Internet")) // <= When i connect to the server from another network
             {
                 networkAddress = "MyPublicLinuxIp"; // I keep it secret
                 OnClickConnect();
             }
             GUILayout.EndHorizontal();
         }
 
         // I am connected
         if (myself != null && myself.isConnected)
         {
             if (GUILayout.Button("Deconnection"))
             {
                 StopClient();
             }
         }
 
         GUI.Window(0, new Rect(0, Screen.height - logWindowSize.y, logWindowSize.x, logWindowSize.y), LogsDisplayer, "Informations");
     }
 
     /// <summary>
     /// Windows which display logs
     /// </summary>
     void LogsDisplayer(int id)
     {
         GUILayout.BeginVertical();
         logScrollBar = GUILayout.BeginScrollView(logScrollBar);
 
         for (int i = 0; i < allLogs.Count; i++)
             GUILayout.Label(allLogs[i]);
 
         GUILayout.EndScrollView();
         if (GUILayout.Button("Clear Logs"))
             allLogs.Clear();
         GUILayout.EndVertical();
     }
 
     /// <summary>
     /// Add a log in log displayer
     /// </summary>
     /// <param name="msg">Log à ajouter</param>
     void AddLogs(string msg)
     {
         allLogs.Add(msg);
         logScrollBar.y += 100;
     }
 
     /// <summary>
     /// Check if connection is timeOut
     /// </summary>
     IEnumerator TestConnectionTimeout()
     {
         yield return new WaitForSeconds(3.0f);
         if (!myself.isConnected)
         {
             AddLogs("Connection failed...");
         }
     }
 
 
     // EVERY FUNCTIONS DOWN ARE MESSAGES FROM UNITY AND UNET
     // I SUPPOSE WE DON'T CARE HERE...
 
     #region Match Messages
 
     public override void OnMatchCreate(CreateMatchResponse matchInfo)
     {
         base.OnMatchCreate(matchInfo);
         print("OnMatchCreate()");
     }
 
     public override void OnMatchList(ListMatchResponse matchList)
     {
         base.OnMatchList(matchList);
         print("OnMatchList");
     }
 
     #endregion
 
     #region Client Messages
 
     public override void OnClientConnect(NetworkConnection conn)
     {
         base.OnClientConnect(conn);
         StopCoroutine("TestConnectionTimeout");
         AddLogs(string.Format("Connection successfull to {0} port {1}", myself.serverIp, myself.serverPort));
         logScrollBar.y += 30;
         //StartCoroutine(DoesMatchMakingExist());
     }
 
     public override void OnClientError(NetworkConnection conn, int errorCode)
     {
         base.OnClientError(conn, errorCode);
         AddLogs("Error " + errorCode + " avec le client " + conn.connectionId);
         logScrollBar.y += 30;
     }
 
     public override void OnStartClient(NetworkClient client)
     {
         base.OnStartClient(client);
         AddLogs("Try to connect to " + networkAddress + " ...");
         logScrollBar.y += 30;
     }
 
     public override void OnClientDisconnect(NetworkConnection conn)
     {
         base.OnClientDisconnect(conn);
         AddLogs("Disconnected from server...");
         logScrollBar.y += 30;
     }
 
     public override void OnClientNotReady(NetworkConnection conn)
     {
         base.OnClientNotReady(conn);
         AddLogs("Disconnected ...");
         logScrollBar.y += 30;
     }
 
     public override void OnStopClient()
     {
         base.OnStopClient();
 
         // On repasse le curseur de la souris normal 
         Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
 
         // On kill le GUI du player
         foreach (PlayerController p in myself.connection.playerControllers)
         {
             if (p.unetView.isLocalPlayer)
             {
                 Destroy(p.unetView.GetComponent<Player>().playerUI);
             }
         }
 
         if (myself != null)
             myself.Disconnect();
         AddLogs("Disconnection successful");
     }
 
     #endregion
 
     #region Server Message
 
     public override void OnStartServer()
     {
         base.OnStartServer();
         AddLogs("Server is ready to be connected to");
     }
 
     public override void OnServerConnect(NetworkConnection conn)
     {
         base.OnServerConnect(conn);
         AddLogs(string.Format("Connection number {0} establish", conn.connectionId));
     }
 
     public override void OnServerRemovePlayer(NetworkConnection conn, PlayerController player)
     {
         base.OnServerRemovePlayer(conn, player);
         AddLogs(string.Format("Server remove player {0} from connectionId {1} ", player.playerControllerId, conn.connectionId));
     }
 
     #endregion
 }
 
              Your answer
 
             Follow this Question
Related Questions
How can I send app unity between two devices via bluetooth (2 smartphone android) 0 Answers
Cameras focused on Host (Unity Multiplayer) 0 Answers
Any way to spawn 2 different Game Objects when doing multiplayer? 1 Answer
Multiplyaer FPS sprint speed does not work 1 Answer
Coroutine in Awake function on Network project doesn't work 0 Answers