Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UNet sometimes disconnects randomly for some users

Discussion in 'UNet' started by light766, Nov 14, 2018.

  1. light766

    light766

    Joined:
    Apr 23, 2009
    Posts:
    250
    I have been developing a MMO game that contains roughly 1000 users per server, the way i attempted to accomplish this is by using UNet HLAPI along with a Network Manager to handle the initial connection. My problem is once i play with 2 of my friends, randomly 1 of those users will just disconnect. They will attempt to send messages to the server but the server never receives them. We initially thought this was a coding error somewhere but we could not find where the error would occur as the game is pretty simple in how it sends messages and the disconnection would just would randomly occur. I have tried recreating the problem countless times, and cant find the source but i have a hunch it is when too much data gets sent at 1 time to the server potentially, tho im not sending anything more than a 20 character string once in a blue moon, all messages are usually just rounded up positions to save data. The rate im sending positional data is 3.5 times a second which i think is quite low.

    I found in old posts to increase the max delay but increasing it too much makes it feel semi laggy and not sure how that would work out with 1000 clients connected, which i would like to avoid creating more lag. If anyone has insight on how to fix this would be a lot of help.

    Any feedback is appreciated, thank you in advance.

    NOTE: we are using strong servers from AWS, so network reliability is not a issue.

    Client to server is usually just a [Command] void that i send to the server.


    The way my game sends messages from the server to the client is quite simple :

    Code (CSharp):
    1.  
    2. void Start(){
    3. ...
    4.  
    5. if(isLocalPlayer){
    6.  
    7.     NetworkManager.singleton.client.RegisterHandler(MsgType.Highest + 5, OnTableMessage);
    8.  
    9. }
    10.  
    11. ...
    12. }
    13.  
    14. ...
    15.  
    16. public void sendBackMessage(string mess){
    17.      
    18.         TableMessage msg = new TableMessage ();
    19.         string temp = mess;
    20.  
    21.     msg.msgData = System.Text.Encoding.UTF8.GetBytes (temp);
    22.  
    23.     NetworkServer.SendToClient (gameObject.GetComponent<NetworkIdentity> ().connectionToClient.connectionId, MsgType.Highest + 5, msg);
    24.  
    25. }
     
    Last edited: Nov 14, 2018
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I encountered a similar problem when building a Unet based MMO. I was getting messages spammed into the player log, but forget the exact message. It was to the effect of a buffer being full. Are you getting any messages in your log/console either on the server or client?
     
  3. light766

    light766

    Joined:
    Apr 23, 2009
    Posts:
    250
    Currently no messages of errors anywhere of a buffer being filled in either the client or server.

    If transitioning to another networking platform is the solution here, what is something that i can transition to with not too much rework.

    We have been developing this server for the past year and would not like to reset if possible because of a bug.

    Here are my server settings if this helps:

     
    Last edited: Nov 15, 2018
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847