WebGL - wws - Could not resolve host 'xxxx-xxx-xxx.relay.cloud.unity3d.com' for all Regions

Hey guys,

I didn’t want to post this, because it looked like a duplicate of: Bug - When using websockets (wss), randomly getting “Could not resolve host” - Unity Forum , but I’m posting this because nslookup is unable to find these adresses, unlike the OP of that post.

  • Unity Transport version: 2.1.0
  • Multiplayer Transport version: 2.0.0-pre.5 (also on 1.1.0)
  • Netcode for GameObjects version: 1.6.0
  • Windows, Unity version 2022.3.10f1 (also on 9f1 and 7f1)

Could not resolve host ‘5067838868696220613-asia-southeast1.relay.cloud.unity3d.com
Could not resolve host ‘8514982339182033011-europe-west2.relay.cloud.unity3d.com
Could not resolve host ‘8664670775605701622-us-central1.relay.cloud.unity3d.com
Could not resolve host ‘6692641278996942651-us-east4.relay.cloud.unity3d.com
Could not resolve host ‘3617200985731427869-us-west2.relay.cloud.unity3d.com
Could not resolve host ‘5947339787419495033-northamerica-northeast1.relay.cloud.unity3d.com
Could not resolve host ‘1320204685726558570-europe-north1.relay.cloud.unity3d.com
Could not resolve host ‘1450957508992543708-asia-southeast2.relay.cloud.unity3d.com
Could not resolve host ‘1575167568055872468-australia-southeast1.relay.cloud.unity3d.com
Could not resolve host ‘1122584560309002119-europe-west4.relay.cloud.unity3d.com
Could not resolve host ‘8744048819277114327-asia-south1.relay.cloud.unity3d.com
Could not resolve host ‘3460821445526924250-europe-central2.relay.cloud.unity3d.com
Could not resolve host ‘3953062647979551685-asia-northeast1.relay.cloud.unity3d.com
Could not resolve host ‘7657495464315431846-southamerica-east1.relay.cloud.unity3d.com
Could not resolve host ‘1135293106547043266-asia-northeast3.relay.cloud.unity3d.com


public async Task<(RelayServerData, Allocation)> GetRelayServerData()
        {
            var allRegions = await RelayService.Instance.ListRegionsAsync();

            RelayServerData relayServerData;

            foreach (var region in allRegions)
            {
                try
                {
                    Debug.Log($"Trying to create allocation in region: {region.Id}");
                   
                    Allocation allocation = await RelayService.Instance.CreateAllocationAsync(4, region.Id);

                    relayServerData = new RelayServerData(allocation, "wss");

                    return (relayServerData, allocation);
                } catch (Exception e)
                {  
                    Debug.LogError($"Error: {e.Message}");
                    continue;
                }
            }

            throw new Exception("No allocation could be created");
        }

Seems like a bug, or an issue with the dns. I get this in the Editor and in the WebGL build.

Same here. We had this occassionally for the last few weeks, since this morning it has worsened, at least for us. At the time of writing no-one from my team can connect at all and we didin’t change anything from last week when it (mostly) worked.

9411491--1318070--upload_2023-10-16_10-55-32.png

We are using:
WebGL
Unity 2022.3.7f1
NGO 1.6.0
Transport 2.0.2
Relay 1.0.5
Lobby 1.1.0
Dedicated game server on Mulitplay

Hello, we’re having the same issue since today.
It has been working without any issue for months.
Then suddenly it doesn’t work anymore. Neither in Editor or Build (Android). We didn’t change anything on our side.
nslookup returns “Server failed” as well.

Android
Unity 2022.3.4f1
NGO 1.5.2
Transport 2.1.0
Relay 1.0.5
Lobby 1.1.0

And now it’s working again. Didn’t change anything.
Probably some problem on Unity’s side.

The problem seems to have fixed itself yesterday around 17:30 CET.

Not from here - still getting this pretty much always as of this morning:
Could not resolve host '5947339787419495033-northamerica-northeast1.relay.cloud.unity3d.com

This is getting ridiculous, just happend again…

Yep, it resolved itself for a few days, but it’s been happening again for a while now.
We can’t use multiplayer, nor our clients…

Do you know of any statement Unity has released of this issue?

One of colleagues just had this problems again. His DNS server was set to the DSN of google (8.8.4.4), when we changes that to Cloudflare DNS (1.1.1.1) it worked on his machine.

DNS Lookup - Check All DNS Records for Any Domain (dnschecker.org)

It seems that DNS server of google has no records of the URL, but Cloudflare does…


This seems to be the problem. Is there anyway to force Cloudflare DNS in a WebGL build?

I have found a fix, the IP that the DNS need to return is something that the allocation already have for the other connection types. I used that IP to make the connection, this is not trivial because the HostString in the RelayServerData needs to have the correct hostname for the secure connection.

How to fix this:

  1. Make sure you copy the Unity Transport package to your Unity environment, in the Packages folder (so it is a custom package)
    9443996--1325120--upload_2023-11-1_12-6-23.png
  2. Comment out Endpoint = HostToEndpoint(endpoint.Host, (ushort)endpoint.Port);
#if RELAY_SDK_INSTALLED
        /// <summary>Create a new Relay server data structure from an allocation.</summary>
        /// <param name="allocation">Allocation from which to create the server data.</param>
        /// <param name="connectionType">Type of connection to use ("udp", "dtls", "ws", or "wss").</param>
        public RelayServerData(Allocation allocation, string connectionType)
            : this(allocation.AllocationIdBytes, allocation.ConnectionData, allocation.ConnectionData, allocation.Key)
        {
            // We check against a hardcoded list of strings instead of just trying to find the
            // connection type in the endpoints since it may contains things we don't support
            // (e.g. they provide a "tcp" endpoint which we don't support).
            if (connectionType != "udp" && connectionType != "dtls" && connectionType != "ws" && connectionType != "wss")
                throw new ArgumentException($"Invalid connection type: {connectionType}. Must be udp, dtls, or wss.");

#if UNITY_WEBGL
            if (connectionType == "udp" || connectionType == "dtls")
                DebugLog.LogWarning($"Relay connection type is set to \"{connectionType}\" which is not valid on WebGL. Use \"wss\" instead.");
#endif

            IsWebSocket = connectionType == "ws" || connectionType == "wss" ? (byte)1 : (byte)0;

            foreach (var endpoint in allocation.ServerEndpoints)
            {
                if (endpoint.ConnectionType == connectionType)
                {
                    //Endpoint = HostToEndpoint(endpoint.Host, (ushort)endpoint.Port);
                    IsSecure = endpoint.Secure ? (byte)1 : (byte)0;
                    HostString = endpoint.Host;
                }
            }
        }
  1. Now add the Endpoint yourself:
JoinAllocation joinAllocation;

            try
            {
                joinAllocation = await RelayService.Instance.JoinAllocationAsync(joinCode);
            }
            catch (Exception e)
            {
                throw new FailedToJoinAllocationException(e.Message);
            }

            var ip = joinAllocation.ServerEndpoints.First(s => !s.Host.Contains("unity")).Host;
            var endpoint = joinAllocation.ServerEndpoints.First(s => s.Host.Contains("unity"));

            RelayServerData relayServerData = new RelayServerData(joinAllocation, "wss");
            relayServerData.Endpoint = NetworkEndpoint.Parse(ip, (ushort)endpoint.Port, NetworkFamily.Ipv4);
                            
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(relayServerData);

This way the HostString is correct for the STL handshake and the NetworkEndpoint contains the correct IP address.

Apparently connected with an IP does not work with WebGL, so this only works on iOS and Android :frowning:

Any additional help is appreciated.

@FdenUijl Thank you so much for the fix. It is working now.

Hi All,
We have observed this behaviour with Google DNS servers, we are looking into it.
Thank you for your patience.

There might be issues with the other DNS servers as well. I was only able to confirm that Cloudflare DNS worked and Google DNS did not over a couple of days.

Any new updates?

Hi all, We’ve just released a few improvements to our internal DNS servers. This should make Google DNS better resolve relay addresses now.
Thank you for your patience and let us know if you still experience this issue.