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. Dismiss Notice

Bug Relay sometimes does not exist on unstable internet

Discussion in 'Relay' started by AOSandberg, May 15, 2023.

  1. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    I am having trouble with the relay service and how unstable it is. I am not using the lobby service. I have used the documentation provided by unity but it is still unstable and I'm unable to figure out what is going wrong. I can create the relay, this works every time and I get a relay code back. The result of the relayServerData.Result returns true. I call StartHost() that also returns true. I subscribe to OnServerStarted from (NetworkManager.Singleton.OnServerStarted) which is also called. Everything seems to work, but when clients tries to join, the relay does not exist. This makes no sense to me because there are no errors and everything check returned as it should. I need some way of knowing if it failed... I'm using the relay for mobile, and one thing I noticed is that the error only happens on semi-bad internet. Using my computer with ethernet never produce this error.
     
  2. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
    What Relay, Netcode for GameObject and Unity version are you using?
     
  3. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    Relay: 1.0.5, Netcode for GameObject: 1.1.0, unity version: 2021.3.15f1
     
  4. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
    You can update Netcode and Unity to the latest version.
    Unity : 2021.3.25f1
    Netcode : 1.4.0

    If this issue still exists, can you share the code?
     
  5. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    Yes, ill get back to you
     
  6. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    netcode: 1.4.0 does not exists? the latest version is 1.2.0?
     
  7. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
  8. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    Okay it is installed, but im getting the same error.. however, I get this warning now: [Netcode] Runtime Network Prefabs was not empty at initialization time. Network Prefab registrations made before initialization will be replaced by NetworkPrefabsList.
     
  9. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    This is my code:
    Host:
    upload_2023-5-15_14-15-54.png

    Client:

    upload_2023-5-15_14-16-56.png

    The problem is that the host is starting, but then sometimes the client cannot join getting an error 404. The host is no throwing any errors and is writing "synching to clients" in the console
     
  10. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
    Can you send relayServerData to NetworkManager like this: UGSNetworkManager.Singleton.StartHost(relayServerData);
    And disable ...SetRelayServerData line.

    In my opinion, relay server is closing after TTL time.
     
  11. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    Nothing with that name
    upload_2023-5-15_15-37-6.png
     
  12. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    The host is syncing which means the server should not have closed no?
     
  13. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
  14. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    It is not a valid function
    upload_2023-5-15_15-46-33.png
    It may be a problem with the connection ttl but shouldn't return a callback saying it failed or died then
     

    Attached Files:

  15. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
    Sorry my bad.
    Your script is correct.
    Do you get "[Netcode] Syncing Time To Clients" log on editor debug. When you start the Host?
     
  16. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    yes, every time... and I can connect with the clients some times.
    upload_2023-5-15_15-53-38.png
     
  17. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    There is no indication that nothing is wrong. Only that the clients sometimes cannot join and the relay cannot be found even tho the host is still syncing
     
  18. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    156
    How about your relay dashboard? Did you configured relay on Dashboard?
     
  19. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    yes, it is working, only some times is does not

    upload_2023-5-15_16-3-52.png
     
  20. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    Client connecting
    upload_2023-5-15_16-8-30.png
    client failing to connect:
    upload_2023-5-15_16-12-11.png
     
  21. j-brown

    j-brown

    Unity Technologies

    Joined:
    Oct 18, 2021
    Posts:
    2
    Hi @AOSandberg, thanks for posting and providing details about your issue.

    Netcode for GameObjects will sends a heartbeat to keep the Relay server alive, by default this happens every 500 milliseconds. Can you check if you've modified this value (heartbeat timeout) in the Netcode for GameObjects configuration? If the value is too large, it could cause the Relay server to timeout before it receives the heartbeat.

    Could you also try connecting with "udp" instead of "dtls" to see if this makes a difference?
    Code (CSharp):
    1. var relayServerData = new RelayServerData(allocation, "udp");
    Finally since you mention the issue only happens on mobile, does the application stay open at all times (not running the background)? When apps are moved to the background, Netcode for GameObjects can no longer send a heartbeat, and the OS usually closes the socket which would also cause the Relay server to timeout.
     
  22. AOSandberg

    AOSandberg

    Joined:
    Sep 9, 2020
    Posts:
    15
    The app is always open, so it is not running in the background. THe transport is as follows: upload_2023-5-17_21-51-56.png