Search Unity

Where to set the timeout for a failed client connection

Discussion in 'Multiplayer' started by Razieln64, Jun 10, 2015.

  1. Razieln64

    Razieln64

    Joined:
    May 3, 2008
    Posts:
    129
    Hi,

    I'm just trying some very basic stuff. I want to connect a client to a server. I used one of the provided examples. I works well for most cases except one.

    When I try to connect to a closed server, the timeout delay to receive an error message telling me the host is unreachable is too long. It takes forever to receive the message. Where can I configure a shorter timeout?

    Also, I can just spam my connection button when my server is closed and before I get my timeout messages I start the server app and I get host id errors. This is probably because all the connection calls try to connect at once on the server. Is there some way to know the state of the client connection status and make is so that if it is connecting it will not try again until it received the connection error message?
     
  2. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    472
    If you're using a NetworkManager, you can set it in the inspector, under Timeouts. If not, you can specify a ConnectionConfig with your NetworkClient, NetworkServer, or HostTopology.
     
  3. Razieln64

    Razieln64

    Joined:
    May 3, 2008
    Posts:
    129
    Hi,
    Thank you!

    When my server is offline it works as intended, but when it is online, I cannot connect anymore. I get CRC Mismatch.

    It seems to not work anymore when I set the configuration using the default ConnectionConfig instance.
     
    Last edited: Jun 10, 2015
  4. Razieln64

    Razieln64

    Joined:
    May 3, 2008
    Posts:
    129
    On a side note, inheritance in network messaging doesn't work. I get serialization error messages from UNetWeaver.

    I would have liked to implement the Command pattern through a network connection but inheritance is not working in this situation. I've also tried templates and it is what is causing the serialization error. Also setting private fields and trying to get their values through properties is also not working. Only public fields work. I am wondering why Unity went with classes. In the documentation which is not up to date they use structs and it makes much more sense since using classes doesn't add anything. It actually makes things worse by using more memory on the heap when creating object instances. I just don't understand why they did this.

    I'm kind of disappointed... But then again I wasn't expecting much. :(

    Edit: So basically it's possible to set fields private and still be able to send their values through a connection. You just have to override Deserialize and Serialize and it will work fine. This is also the reason they went with classes instead of structs. Because there's no inheritance if you use structs and the we wouldn't be able to override the serialization/deserialization methods.
     
    Last edited: Jun 11, 2015