Search Unity

Need to increase network timeout

Discussion in 'Multiplayer' started by Davedub, Jul 20, 2017.

  1. Davedub

    Davedub

    Joined:
    Mar 30, 2016
    Posts:
    22
    Hi,

    My networked single PC / multiple GearVR project is up and running. However, as part of the use case for the system, we need to be able to take the headsets on and off during the experience, often leaving breaks of up to 20 minutes.

    The problem is that when the headset is taken off the app goes into some sort of pause mode. This will cause the host to report an error after a short while:

    ServerDisconnected due to error: Timeout
    UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

    After this error has occurred the system no longer functions, as the connection between the host and client is broken. So, what I need is to find a way to extend the network timeout to 20 minutes. I have scoured the docs for a way to control this, but have found nothing. I have tried adjusting the timeout values in Network Manager -> Advanced Configuration, but with no success.

    The other option is to somehow re-initialise the network when the timeout occurs, but since my system first uses network discovery to find the host IP address before switching to regular UNET operation, this seems to be a very long way round - I'd much prefer a way to either disable the network timeout or to at least extend it to 20 minutes.

    Any help gratefully received!

    - davedub
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Are you using the relay?
     
  3. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    574
    +1 @TwoTen, if you do not use relay, you can implement something like:
    Client which is going to suspend: "I'm going to suspend"
    Server: "Suspend confirmed"
    Client - disconnects...

    Disconnect timeout increasing won't help here.
     
  4. Davedub

    Davedub

    Joined:
    Mar 30, 2016
    Posts:
    22
    Thank you for the replies.

    @TwoTen - no, I'm not using a relay.

    @aabramychev - I have made further tests and am finding the timeout is even shorter if I don't use the GearVR. The behaviour is identical to what is described here (although I'm not using matchmaker):

    http://answers.unity3d.com/questions/1013772/unet-timeout.html

    With your proposed solution, where would I catch the 'I'm going to suspend' event?

    Alternatively, I'm thinking about catching the client disconnect event and attempting to reconnect, but so far I can't seem to capture the event, despite overriding the following on my NetworkManager:

    OnStopClient, OnClientDisconnect, OnServerDisconnect, OnClientError and OnServerError

    and implementing the following, also on my NetworkManager:

    OnApplicationFocus, OnApplicationPause, OnDisconnectedFromServer and OnPlayerDisconnected

    I'm guessing that the fact I can't seem to capture any event that signals the loss of connection means that either the UNET system is buggy, or I'm missing something quite fundamental...

    Any advice gratefully received!

    - davedub