Hi! I’m currently implementing Relay connection on my project. Everything works fine until I try to connect a client to the relay, which gives me the erro “Relay code no found”. I followed the Using Relay with NGO documentation and I’m using Relay Unity Transport as the Protocol. I’ve read a few threads about this problem but none of them worked.
Here’s the Allocation code:
Allocation allocation = await Relay.Instance.CreateAllocationAsync(2);
RelayData data = new RelayData
{
IPv4Address = allocation.ServerEndpoints.Find(item => item.ConnectionType == ("dtls")).Host,
Port = (ushort)allocation.ServerEndpoints.Find(item => item.ConnectionType == ("dtls")).Port,
AllocationID = allocation.AllocationId,
AllocationIDBytes = allocation.AllocationIdBytes,
ConnectionData = allocation.ConnectionData,
Key = allocation.Key
};
string joinCode = await RelayBaseServices.GetJoinCode(data.AllocationID);
NetworkManager.Singleton.GetComponent<UnityTransport>().SetHostRelayData(
data.IPv4Address,
data.Port,
data.AllocationIDBytes,
data.Key,
data.ConnectionData
);
NetworkManager.Singleton.StartHost();
And here’s the code to JoinAllocation:
JoinAllocation allocation = await Relay.Instance.JoinAllocationAsync(_currentlobby.Data["RelayJoinCode"].Value);
RelayData data = new RelayData
{
IPv4Address = allocation.ServerEndpoints.Find(item => item.ConnectionType == ("dtls")).Host,
Port = (ushort)allocation.ServerEndpoints.Find(item => item.ConnectionType == ("dtls")).Port,
AllocationID = allocation.AllocationId,
AllocationIDBytes = allocation.AllocationIdBytes,
ConnectionData = allocation.ConnectionData,
Key = allocation.Key,
HostConnectionData = allocation.HostConnectionData
};
NetworkManager.Singleton.GetComponent<UnityTransport>().SetClientRelayData(
data.IPv4Address,
data.Port,
data.AllocationIDBytes,
data.Key,
data.ConnectionData,
data.HostConnectionData
);
NetworkManager.Singleton.StartClient();
As you can see, I’m not calling JoinAllocation for the Host, as in this Thread ( Relay: Code Not Found ). And I immediatly call StartHost() and StartClient(), which should be enough to keep the connection alive, but it does not and 10 seconds later i get “relay code not found” if I try to connect (If I connect within 10 seconds the connection works fine). this Thread ( How to keep Relay connection alive using NGO? ) suggests a test using Interactive Relay Sample, I did the test and this error shows up even in the sample:
I would REALLY appreciate some help. Thank you!