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 Unity relay failed to join relay 404 error

Discussion in 'Relay' started by gearup117, Jul 9, 2023.

  1. gearup117

    gearup117

    Joined:
    Apr 2, 2020
    Posts:
    1
    This is my creating relay code. But sometimes client isn't unable to join. Its gives relay code doesn't exists 404 error
    //Only called when Starting as host
    private async void AllocateRelay()
    {
    try
    {
    Allocation joinAllocation = await RelayService.Instance.CreateAllocationAsync(4);
    m_RealyCode = await RelayService.Instance.GetJoinCodeAsync(joinAllocation.AllocationId);

    NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(new RelayServerData(joinAllocation, "dtls"));
    NetworkManager.Singleton.StartHost();
    Debug.Log("Create relay " + m_RealyCode);
    }
    catch (Exception e)
    {
    Debug.Log(e);
    OnAllocateRelayFailed?.Invoke();
    LoadingUI.Instance.Show($"Failed to create game. Try again", 2f);
    CustomSceneManager.Instance.LoadScene(SceneInfo.Startup);
    }
    }
     
  2. binarymaus

    binarymaus

    Joined:
    Mar 15, 2020
    Posts:
    2
    I'm experiencing the same error with Version 1.1.0-pre.5.
     
  3. UnityKristy

    UnityKristy

    Joined:
    Mar 9, 2014
    Posts:
    2
    Not sure if it's deprecated, but this works consistently for me:

    Code (CSharp):
    1.             NetworkManager.Singleton.GetComponent<UnityTransport>().SetHostRelayData(
    2.                 createAllocation.RelayServer.IpV4,
    3.                 (ushort)createAllocation.RelayServer.Port,
    4.                 createAllocation.AllocationIdBytes,
    5.                 createAllocation.Key,
    6.                 createAllocation.ConnectionData
    7.                 );