Search Unity

UNet - Timeout error

Discussion in 'UNet' started by Clicksurfer, Apr 9, 2020.

  1. Clicksurfer

    Clicksurfer

    Joined:
    Aug 17, 2014
    Posts:
    77
    Hey everyone, I have quite a pickle related to Unity's currently-being-deprecated Networking system, UNet.

    I have a LAN game with a host and clients, where players write the IP of the host server they want to connect to and they connect successfully. No problems there.

    The problem is when they specify a wrong IP address, and try to connect to this IP (using the
    NetworkManager.singleton.StartClient();
    command), I get the following error:
    ClientDisconnected due to error: Timeout


    This is, of course, expected, but the problem is there's a big delay between the player sending the request until him getting the error.
    If, for example, during this time he puts a valid IP address of a host and connects to it, the timeout of the previous request will still cause him to disconnect! This is obviously not good for me.

    I see two possible ways to fix this:
    1. Make the client validate that such an IP exists in the network before trying to connect to it at all
    2. Override the Timeout code so it will disconnect the player only if the IP he didn't succeed with is the IP he's "in-session" with now.

    Have any of you done something like this before? I would love to get some advice from you on how to do this, as I was not able to find the correct function to override, nor do I have any idea how to validate the host IP before attempting to join it.

    Much thanks in advance!