Relay drop down my connection and client doens't connect

Hello,

I’m having a double issue when I try to use Relay, I show you my two methods:

   public   async void CreateRelay()
        {
            try
            {

                Allocation allocation = await RelayService.Instance.CreateAllocationAsync(2);

                string joinCode = await RelayService.Instance.GetJoinCodeAsync(allocation.AllocationId);
                RelayServerData relayServerData = new RelayServerData(allocation, "dtls");
                NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);
                Debug.Log("TestRelay --> join code " + joinCode);
                codeToShow.text = joinCode;
                NetworkManager.Singleton.StartHost();
                SetPlayerID();
            }
            catch (RelayServiceException e)
            {
                Debug.Log(e.Message);
            }

        }

     public   async void JoinCode()
        {
            try
            {
                string joinCode = codeToRetrieve.text;
                Debug.Log("joined with this code : " + joinCode);
                JoinAllocation joinAllocation = await RelayService.Instance.JoinAllocationAsync(joinCode);

                RelayServerData relayServerData = new RelayServerData(joinAllocation, "dtls");
                NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);

                NetworkManager.Singleton.StartClient();
                SetPlayerID();
            }
            catch (RelayServiceException e)
            {
                Debug.Log(e.Message);
            }

        }

I created two buttons on UI, one call CreateRelay when pressed, the second read an InputField (the inputfield is linked by the variable “codeToRetrieve”) and actually the Debug.Log show me the same code I insert.

I create the relay and it connects the game, but when I try to connect the client (the second player), I get this error (my first issue):

Bad Request: invalid request schema or decoding failure
UnityEngine.Debug:Log (object)
Assets.Scripts.Lobby.TestRelay/d__4:MoveNext () (at Assets/Scripts/Lobby/TestRelay.cs:71)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Relay.Models.JoinAllocation>:SetException (System.Exception) Unity.Services.Relay.WrappedRelayService/<JoinAllocationAsync>d__8:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/SDK/WrappedRelayService.cs:171) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Relay.Response1<Unity.Services.Relay.Models.JoinResponseBody>>:SetException (System.Exception) Unity.Services.Relay.Apis.RelayAllocations.RelayAllocationsApiClient/<JoinRelayAsync>d__9:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Apis/RelayAllocationsApi.cs:186) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Relay.Http.HttpClientResponse>:SetResult (Unity.Services.Relay.Http.HttpClientResponse)
Unity.Services.Relay.Http.HttpClient/d__1:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Http/HttpClient.cs:41)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Relay.Http.HttpClientResponse>:SetResult (Unity.Services.Relay.Http.HttpClientResponse) Unity.Services.Relay.Http.HttpClient/<CreateWebRequestAsync>d__3:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Http/HttpClient.cs:56) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Relay.Http.HttpClientResponse>:SetResult (Unity.Services.Relay.Http.HttpClientResponse)
Unity.Services.Relay.Http.HttpClient/d__4:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Http/HttpClient.cs:84)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.Relay.Http.HttpClientResponse>:SetResult (Unity.Services.Relay.Http.HttpClientResponse) Unity.Services.Relay.Http.HttpClient/<>c__DisplayClass4_0/<<CreateHttpClientResponse>b__0>d:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Http/HttpClient.cs:81) System.Threading.Tasks.TaskCompletionSource1<Unity.Services.Relay.Http.HttpClientResponse>:SetResult (Unity.Services.Relay.Http.HttpClientResponse)
Unity.Services.Relay.Http.UnityWebRequestHelpers/<>c__DisplayClass0_0:b__0 (UnityEngine.AsyncOperation) (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Http/UnityWebRequestHelpers.cs:34)
UnityEngine.AsyncOperation:InvokeCompletionEvent ()

The second issue is that after 30 seconds (sometime less) my WiFi connection drop down after I create a Relay

Every library is updated with new version (netcode and relay).
The unity transport is: Relay unity transport

Update on my issue:

I did these steps:

  • Build the game
  • Send the build to my Virtual Machine
  • Run the game in my VM
  • The game starts, the Relay is up (I can see it in my Relay Dashbord)8673084--1168611--upload_2022-12-19_16-28-54.png

The issue still remain if I run the same build on my PC, when I run it, the game stop my WIFI.

I can see the IP and port that ServerData generate from Relay and setted up to my UnityTransport but when I try to ping the IP, I can’t reach it, (neither from VM and my PC).

Question: why my WiFi connection drop down after I create a Relay only on my PC?
Should I do something to my UnityTransport?

Hello VKyuzel,

I have tried running your code here, minus SetPlayerID, and it worked flawlessly.

Two thoughts:

  • Do you get the same problems (Bad request and WiFi disconnection) if you use UDP instead of DTLS?
  • It is normal that you cannot ping the Relay server. They do not answer PINGs.
1 Like

Hello Ptrottier,

Regarding ur thoughts:

  1. I tried now UDP instead of DTLS and nothing changed when I started the game in my editor or by build. The wifi goes down. (luckly in my VM still working)
  2. Thank you for clearify that.

About the code you tried:
Did you try the method JoinCode to join the RelayServer with 2 different machine ?( one host and one client,but different IPs)

I add a pic of my Unity Transport in the inspector as well8673666--1168743--upload_2022-12-19_19-56-14.pngand NetworkManager 8673666--1168746--upload_2022-12-19_19-56-52.png(prefab Player is empty, it has just the NetworkObject attached). And these are my packages installed (I don’t use all of them)8673666--1168749--upload_2022-12-19_19-58-6.png

Another update:
I created a new project to test the code, and I got the same problem, I think that there is something on my PC that drop my WiFi.
Digging in the forum I read taht I have to work with firewall, I enabled it


(Pubblico == Public), (Entrata==Entrance)
Should I have the Firewall on public or in private?

Hey VKyuzel, the WiFi issue is strange. Do you mean that your computer goes completely offline?

When I tried your code, it was on the same machine. The host was a built executable and the peer was in-editor.

Yeah, I mean that my pc, for 5 seconds, goes completely offline, than the connection is restored for my PC but the game is disconnected

Hi guys!
Updating my status:
The code is working like you suggested! I switched from WiFI to Ethernet cable and now it is working on my PC too. The whole problem still going on wifi and I can’t stay everytime with the cable attached to the modem. So the issue is still WiFi and Relay don’t love each other, any tips of their collateral relationship?