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

Too many bugs in UNet

Discussion in 'UNet' started by Femidko, Oct 26, 2015.

  1. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    Unity 5.2.2

    Code (CSharp):
    1. public class MyNetworkManager : NetworkManager
    2. {
    3.         void Start()
    4.         {
    5.             NetworkServer.SetNetworkConnectionClass<MyConnection>();
    6.             StartServer(); // Or StartHost();
    7.         }
    8.         public override void OnServerAddPlayer(NetworkConnection _conn, short _playerControllerId)
    9.         {
    10.             PeonConnection conn = (PeonConnection)_conn; // Error!!!
    11.         }
    12.  
    13. }
    14. public class MyConnection : NetworkConnection
    15. {
    16. }
     
    Last edited: Oct 26, 2015
  2. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    Dont called OnStartClient, OnStartServer, OnStartHost in custom NetworkManager
     
  3. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    Dont worked DontDestroyOnLoad, RunInBackground, AutoCreatePlayer in custom NetworkManager without offline scene.
     
  4. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    God, why do I moved from uLink on to uNet?
     
  5. _Adriaan

    _Adriaan

    Joined:
    Nov 12, 2009
    Posts:
    481
    Look, man, instead of complaining here publicly on the forums, you might want to look into some UNET HLAPI manual and examples, because you are clearly on the wrong path here. A lot of people are working with UNET and don't have any problems with it.
     
  6. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    Good afternoon! Does it look like I'm not know much uNet? A most people are working with UNET use standard solutions. If you make a step away from the standard solutions, the bugs occur. I have listed the real bugs, which since 5.1. You can try them all.
    Here's yet another bug. Crash at the serialization of complex class with standard ClientRpc-Command
    Code (CSharp):
    1.  
    2.  
    3. public class Player : NetworkBehaviour {
    4.  
    5.     [Client]
    6.     public override void OnStartLocalPlayer()
    7.     {
    8.  
    9.         base.OnStartLocalPlayer();
    10.  
    11.         MyClass my = new MyClass();
    12.  
    13.         CmdSendData(my);
    14.  
    15.     }
    16.  
    17.     [Command]
    18.     public void CmdSendData(MyClass _my)
    19.     {
    20.         Debug.Log(_my.ToString());
    21.     }
    22. }
    23. [Serializable]
    24. public class MyClass  {
    25.  
    26.     public MyClass1 aaa;
    27.  
    28.     public MyClass()
    29.     {
    30.  
    31.         aaa = new MyClass1(this);
    32.     }
    33.  
    34. }
    35.  
    36. [Serializable]
    37. public class MyClass1 {
    38.  
    39.     public MyClass aaa;
    40.  
    41.     public MyClass1(MyClass _owner)
    42.     {
    43.         aaa = _owner;
    44.     }
    45.  
    46. }
    Unity just crashes without error messages and any useful information in the logs.
     
  7. MightySheep

    MightySheep

    Joined:
    Sep 23, 2015
    Posts:
    21
    The arguments passed to commands and ClientRpc calls are serialized and sent over the network. These arguments can be:

    • basic types (byte, int, float, string, UInt64, etc)
    • arrays of basic types
    • structs containing allowable types
    • built-in unity math types (Vector3, Quaternion, etc)
    • NetworkIdentity
    • NetworkInstanceId
    • NetworkHash128
    • GameObject with a NetworkIdentity component attached
    taken from http://docs.unity3d.com/Manual/UNetActions.html
    I dont see anything about sending classes here.
     
  8. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    I know that. Do you think it normal that Unity crash without error messages and logs? ))
     
  9. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    classes are not supported for UNet remote actions. That bug was fixed in an editor patch release. Try getting the latest patch.
     
  10. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    Thanks for the answer. I hope that issue with basic types arrays reading/writing to the NetworkReader/NetworkWriter will also be resolved.

    What about the previous real bugs?
     
    Last edited: Oct 30, 2015
  11. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    Some time ago I created a theme in Russian gameDev forum. There's gave an UNet overview. And examples of network architecture with a split source code client and server objects and their networking. With custom class serialization. Maybe it would be useful to someone. Sorry for my English.

    Registrar of custom object types: NetworkCodec.cs (NetworkCodecType.cs, NullableStreamObject.cs)
    Usage is as follows:
    Register:
    Code (CSharp):
    1. NetworkCodec.Add<MyClass>(MyClass.Write, MyClass.Read);
    or:
    Code (CSharp):
    1. NetworkCodec.AddAndMakeArray<MyClass>(MyClass.Write, MyClass.Read);
    Using:
    Code (CSharp):
    1.  
    2.         NetworkCodec.Write<MyClass>(writer, myClassObject);
    3.         MyClass myObject = (MyClass)NetworkCodec.Read<MyClass>(reader);
    4.  
     

    Attached Files:

    Last edited: Nov 2, 2015
  12. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55

    Attached Files:

  13. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    Why would you do this?

    The MessageBase class already generates serialization code automatically
     
  14. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    Do you really believe that creating wrappers (MessageBase ) for each message type is comfortably?
    Maybe I do not understand something. Ok. I have four classes (A,B,C,D) and I need to pass these classes in different messages in different combinations. Abstract I will have to write 16 message wrappers (MessageBase ) for each combination (A,B,C,D; A,B,D,C; A,C,B,D etc). Correctly? And in each wrapper I will still use methods such A.Write, A.Read in order to avoid duplication. Let's add here mutual use of these classes and their arrays. And we have provided work for a week )).

    It is much easier to describe serialization once, a class register in the codec, and then use it in any messages
     
    Last edited: Oct 31, 2015
    Leoo likes this.
  15. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    NetworkServer.connections is empty on host.
     
    Leoo likes this.
  16. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Does it mean the developer has to make the game manually add new connections to NetworkServer.connections?
     
  17. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    NetworkServer.connections is read only. I think it is a bug, and the client connection on the host just is not added to this list. The manual does not say that such a connection should not be on the NetworkServer.connections.

    And about the manual.

    NetworkBehaviour.connectionToServer
    The NetworkConnection associated with this NetworkIdentity. This is only valid for player objects on the server.
    May be: "This is only valid for player objects on the client" ?
     
    Last edited: Nov 3, 2015
    Leoo likes this.
  18. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Felt @seanr could respond for the "bug" mentioned. I may recall it was reported, but no fix for now.
     
    Leoo likes this.
  19. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    Why is an error (!!!) occurs: "UNet Client Disconnect Error: Timeout" on client when the server disconnected?
    Code (CSharp):
    1. public class FP2PClient : NetworkClient
    2. {
    3. public FP2PClient() : base()
    4.                 {
    5.                     ConnectionConfig config = new ConnectionConfig();
    6.                     config.AddChannel(QosType.ReliableSequenced);
    7.                     config.AddChannel(QosType.Unreliable);
    8.                     Configure(config, 1);
    9.  
    10.                     RegisterHandler(MsgType.Connect, OnConnect);
    11.                     RegisterHandler(MsgType.Disconnect, OnDisconnect);
    12.                     RegisterHandler(MsgType.Error, OnError);
    13.  
    14.                     Connect(mServerHost, mServerPort);
    15.                 }
    16.                 public void OnConnect(NetworkMessage _msg)
    17.                 {
    18.                 }
    19.  
    20.                 public void OnDisconnect(NetworkMessage _msg)
    21.                 {
    22.                 }
    23.  
    24.                 public void OnError(NetworkMessage _msg)
    25.                 {
    26.                 }
    27.  
    28. }
    Connect, turn off the server and receives an error. Why is the error?
     
    Leoo likes this.
  20. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    When the client disconnect from server error occurs:
    Example:
    Code (CSharp):
    1. public class FP2PClient : NetworkClient
    2. {
    3. public FP2PClient() : base()
    4.                 {
    5.                     ConnectionConfig config = new ConnectionConfig();
    6.                     config.AddChannel(QosType.ReliableSequenced);
    7.                     config.AddChannel(QosType.Unreliable);
    8.                     Configure(config, 1);
    9.                     RegisterHandler(MsgType.Connect, OnConnect);
    10.                     RegisterHandler(MsgType.Disconnect, OnDisconnect);
    11.                     RegisterHandler(MsgType.Error, OnError);
    12.                     Connect(mServerHost, mServerPort);
    13.                 }
    14.                 public void OnConnect(NetworkMessage _msg)
    15.                 {
    16.                         Disconnect();
    17.                 }
    18.                 public void OnDisconnect(NetworkMessage _msg)
    19.                 {
    20.                 }
    21.                 public void OnError(NetworkMessage _msg)
    22.                 {
    23.                 }
    24. }
     
    Last edited: Nov 11, 2015
    Leoo likes this.
  21. Leoo

    Leoo

    Joined:
    May 13, 2013
    Posts:
    96
  22. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    I'm not sending bug reports, because they are not responding. So when the developer's reply to me was a surprise )).
    By the way, I realized handovering of players to another server. If anyone is interested, I can put the source code
     
  23. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Note that they only respond during business hours. If you send a Wednesday, Thursday, or Friday report, you'll need to wait for more days.

    Source: Have sent out tons of report, got back most of them usually on Mondays and Tuesdays, with rare occurrences on Wednesdays through Fridays.
     
  24. Femidko

    Femidko

    Joined:
    Aug 4, 2013
    Posts:
    55
    I wrote to them not on Mondays and Tuesdays... I wrote to them on August, September, October )))
     
  25. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Ah, they probably expected pictures, GIF, steps to reproduce, detailed debug messages, debug dumps, and a very small reproducible Unity project no bigger than 500KB. Anything over the size limit, or there is something missing, the bug report will have (-1 priority level multiplied by how many kinds of missing info the bug report has).

    They would then order them from critical priority level 6 (highly reproducible crashes) to lowest priority level 0 (irrelevant, won't fix). If you are hitting priority 3 or lower, you'll be waiting for a while before any responses come in.

    /sarcasm
     
    Last edited: Nov 16, 2015
  26. Erik-Juhl

    Erik-Juhl

    Unity Technologies

    Joined:
    Jul 11, 2012
    Posts:
    59
    Please send us bug reports through our bug reporter. Posting bugs to the forums is not the way to get them into our bug database.