When using websockets (wss), randomly getting "Could not resolve host"

Hi! My application is using latest - Relay 1.0.5, Netcode 1.5.1 and Unity 2022.3.4f1.

If I use DTLS/useWebSockets = false, everything works great with my simple host that starts and a client that connects via Relay, and they are able to share data with no issues 100% of the time.

However, if I use wss/useWebSockets set to true, half the time I get an error on starting a host or joining via client, e.g.:
“SocketException: Could not resolve host ‘-us-east4.relay.cloud.unity3d.com’”

I can’t make any sense of this and I need to use wss as I’m trying to eventually get a webGL client with an Android host talking to each other.

Any ideas? TIA!

Hey Travis, we will look into it, thanks for reaching out!
We will get back to you soon

2 Likes

Hey Travis, we are still investigating this.
We might need to have a look at the specific logs in the relay instances you are trying to reach, to locate those, if you can, we will need logs from your side with the full host name (with the unique number) and the time as well.

1 Like

Here’s a couple from yesterday:

client using web sockets:
SocketException: Could not resolve host ‘3044856426977881687-us-east4.relay.cloud.unity3d.com’
System.Net.Dns.Error_11001 (System.String hostName) (at <1726b8fb30b6494e8753e45adcf8a07b>:0)
System.Net.Dns.GetHostByName (System.String hostName) (at <1726b8fb30b6494e8753e45adcf8a07b>:0)
System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) (at <1726b8fb30b6494e8753e45adcf8a07b>:0)
Unity.Networking.Transport.Relay.RelayServerData.HostToEndpoint (System.String host, System.UInt16 port) (at ./Library/PackageCache/com.unity.transport@2.0.2/Runtime/Relay/RelayServerData.cs:237)
Unity.Networking.Transport.Relay.RelayServerData…ctor (Unity.Services.Relay.Models.JoinAllocation allocation, System.String connectionType) (at ./Library/PackageCache/com.unity.transport@2.0.2/Runtime/Relay/RelayServerData.cs:120)
SessionViewerManager.JoinSession (System.String lobbyId) (at Assets/Scripts/Network/SessionViewer/SessionViewerManager.cs:308)
UnityEngine.Debug:LogException(Exception, Object)
Logger:Exception(Exception, GameObject) (at Assets/Scripts/Util/Logger.cs:45)
host using web sockets:
SocketException: Could not resolve host ‘6220039690651203365-us-east4.relay.cloud.unity3d.com’
System.Net.Dns.Error_11001 (System.String hostName) (at <1726b8fb30b6494e8753e45adcf8a07b>:0)
System.Net.Dns.GetHostByName (System.String hostName) (at <1726b8fb30b6494e8753e45adcf8a07b>:0)
System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) (at <1726b8fb30b6494e8753e45adcf8a07b>:0)
Unity.Networking.Transport.Relay.RelayServerData.HostToEndpoint (System.String host, System.UInt16 port) (at ./Library/PackageCache/com.unity.transport@2.0.2/Runtime/Relay/RelayServerData.cs:237)
Unity.Networking.Transport.Relay.RelayServerData…ctor (Unity.Services.Relay.Models.Allocation allocation, System.String connectionType) (at ./Library/PackageCache/com.unity.transport@2.0.2/Runtime/Relay/RelayServerData.cs:95)
SessionViewerManager.CreateSession (System.String org, System.String userId, System.String fullName) (at Assets/Scripts/Network/SessionViewer/SessionViewerManager.cs:118)
UnityEngine.Debug:LogException(Exception, Object)
Logger:Exception(Exception, GameObject) (at Assets/Scripts/Util/Logger.cs:45)
d__11:MoveNext() (at Assets/Scripts/Network/SessionViewer/SessionViewerManager.cs:152)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(Lobby) Unity.Services.Lobbies.Internal.<CreateLobbyAsync>d__4:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/SDK/WrappedLobbyService.cs:67) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(Response1) Unity.Services.Lobbies.Internal.<TryCatchRequest>d__202:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/SDK/WrappedLobbyService.cs:390)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(Response1)
Unity.Services.Lobbies.Apis.Lobby.d__6:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Apis/LobbyApi.cs:236)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(HttpClientResponse) Unity.Services.Lobbies.Http.<MakeRequestAsync>d__3:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:47) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(HttpClientResponse)
Unity.Services.Lobbies.Http.d__7:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:138)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetResult(HttpClientResponse) Unity.Services.Lobbies.Http.<<CreateWebRequestAsync>b__0>d:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:135) System.Threading.Tasks.TaskCompletionSource1:SetResult(HttpClientResponse)
Unity.Services.Lobbies.Http.<>c__DisplayClass0_0:b__0(AsyncOperation) (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/UnityWebRequestHelpers.cs:34)
UnityEngine.AsyncOperation:InvokeCompletionEvent()

Still occurring for me as of today too:

SocketException: Could not resolve host ‘6220039690651203365-us-east4.relay.cloud.unity3d.com’

Hey, thanks! we think this has something to do with the dns. Thanks for the report.

Just if you happen to experience an issue, exactly when you encounter it, could you try the following command:

dig xxxx-us-east4.relay.cloud.unity3d.com

And post the result?
We also have the possiblity that something’s wrong in dotnet…

Instead of using dig (which is used in linux and macOS) one would need to use nslookup on Windows.

1 Like

I can start up a host using web sockets (via editor) and about a 1/4 of the time it succeeds (within the same minute). Here’s the nslookup results:

nslookup 6220039690651203365-us-east4.relay.cloud.unity3d.com
Server: ns3.mpinet.com
Address: 216.53.130.4
Non-authoritative answer:
Name: 6220039690651203365-us-east4.relay.cloud.unity3d.com
Address: 34.86.235.208

Here’s another that just failed for me:

nslookup 5429086089741813659-us-east4.relay.cloud.unity3d.com
Server: ns3.mpinet.com
Address: 216.53.130.4
Non-authoritative answer:
Name: 5429086089741813659-us-east4.relay.cloud.unity3d.com
Address: 34.86.249.189

Note this only occurs when using the new web sockets option.

OK, so just to be clear, the nslookup never fails on your side whereas relay fails to connect to that very same domain 25% of the time when using wss?

That is correct. Nslookup never has failed for me from this machine. Unity Relay displays this error almost all the time but not always which is the strangest part (and only when using web sockets).

What’s strange, when I do an actual build (outside of the editor) I haven’t seen the error yet, so its possible its a editor only odd behavior.

Yeah, that was my next question, you mean a webGL build, right?

Yes when running an actual webGL build I haven’t seen the issue (yet :slight_smile: but I see the issue in editor regardless of platform (when using web sockets).

OK, it confirms our other theory, that the issue was in dot net, since the webGL build code path is using the WebSocket javascript API.
We will have to contact people that are deeper within the engine to solve this one.
Thanks for your precious feedback Travis!

Gotcha, I was afraid it was be a far more complicated problem. Appreciate the effort looking into it (strange how no one else has reported it).

FWIW, right now I just have a loop of multiple attempts (delaying between each) doing the SetRelayData which triggers the error. The odd thing is sometimes it’ll set and work fine after < 10 tries, whereas other times takes almost 100 retries! (And sometimes yet it still never succeeds and I have to restart the app in editor and try again). But strangely, sometimes the SetRelayData does succeed but then the allocation will fail right after with these errors (not sure if thats helpful or not to the team :smile:):

Received error message from Relay: allocation ID not found.
0x00007ff6d7d886da (Unity) DefaultBurstRuntimeLogCallback
0x00007ff6d745b11a (Unity) BurstCompilerService_CUSTOM_RuntimeLog
0x00007ffc69e4a321 (eb19c3fa31f075a5294c00b580dd1dd) Unity.Networking.Transport.Logging.DebugLog.ErrorRelay (at C:/dev/tap-unity-simulation-webgl/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/Library/PackageCache/com.unity.transport@2.0.2/Runtime/DebugLog.cs:171)
0x00007ffc69e545e7 (eb19c3fa31f075a5294c00b580dd1dd) Unity.Networking.Transport.RelayLayer.ReceiveJob1<Unity.Networking.Transport.UnderlyingConnectionList>.ProcessReceivedMessages (at C:/dev/tap-unity-simulation-webgl/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/Library/PackageCache/com.unity.transport@2.0.2/Runtime/Layers/RelayLayer.cs:303)* *0x00007ffc69e52623 (eb19c3fa31f075a5294c00b580dd1dd) Unity.Jobs.IJobExtensions.JobStruct1<Unity.Networking.Transport.RelayLayer.ReceiveJob1<Unity.Networking.Transport.UnderlyingConnectionList>>.Execute(ref Unity.Networking.Transport.RelayLayer.ReceiveJob1<Unity.Networking.Transport.UnderlyingConnectionList> data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) → void_74ba8063da5254ef739219263a3da2e5 from UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (at C:/dev/tap-unity-simulation-webgl/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/unknown/unknown:0)
0x00007ffc69e51f36 (eb19c3fa31f075a5294c00b580dd1dd) 8de023688c1b71ddd3534988b741c831
0x00007ff6d806c8bc (Unity) ExecuteJob
0x00007ff6d806dc7f (Unity) ForwardJobToManaged
0x00007ff6d80698dc (Unity) ujob_execute_job
0x00007ff6d8068fc4 (Unity) lane_guts
0x00007ff6d806bb24 (Unity) worker_thread_routine
0x00007ff6d82989a7 (Unity) Thread::RunThreadWrapper
0x00007ffcc82026ad (KERNEL32) BaseThreadInitThunk
0x00007ffcc8e6aa68 (ntdll) RtlUserThreadStart
Relay allocation is invalid. See NetworkDriver.GetRelayConnectionStatus and RelayConnectionStatus.AllocationInvalid for details on how to handle this situation.
0x00007ff6d7d886da (Unity) DefaultBurstRuntimeLogCallback
0x00007ff6d745b11a (Unity) BurstCompilerService_CUSTOM_RuntimeLog
0x00007ffc69e4a340 (eb19c3fa31f075a5294c00b580dd1dd) Unity.Networking.Transport.Logging.DebugLog.ErrorRelay (at C:/dev/tap-unity-simulation-webgl/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/Library/PackageCache/com.unity.transport@2.0.2/Runtime/DebugLog.cs:171)
0x00007ffc69e545e7 (eb19c3fa31f075a5294c00b580dd1dd) Unity.Networking.Transport.RelayLayer.ReceiveJob1<Unity.Networking.Transport.UnderlyingConnectionList>.ProcessReceivedMessages (at C:/dev/tap-unity-simulation-webgl/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/Library/PackageCache/com.unity.transport@2.0.2/Runtime/Layers/RelayLayer.cs:303)* *0x00007ffc69e52623 (eb19c3fa31f075a5294c00b580dd1dd) Unity.Jobs.IJobExtensions.JobStruct1<Unity.Networking.Transport.RelayLayer.ReceiveJob1<Unity.Networking.Transport.UnderlyingConnectionList>>.Execute(ref Unity.Networking.Transport.RelayLayer.ReceiveJob1<Unity.Networking.Transport.UnderlyingConnectionList> data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) → void_74ba8063da5254ef739219263a3da2e5 from UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (at C:/dev/tap-unity-simulation-webgl/Library/PackageCache/com.unity.burst@1.8.7/.Runtime/unknown/unknown:0)
0x00007ffc69e51f36 (eb19c3fa31f075a5294c00b580dd1dd) 8de023688c1b71ddd3534988b741c831
0x00007ff6d806c8bc (Unity) ExecuteJob
0x00007ff6d806dc7f (Unity) ForwardJobToManaged
0x00007ff6d80698dc (Unity) ujob_execute_job
0x00007ff6d8068fc4 (Unity) lane_guts
0x00007ff6d806bb24 (Unity) worker_thread_routine
0x00007ff6d82989a7 (Unity) Thread::RunThreadWrapper
0x00007ffcc82026ad (KERNEL32) BaseThreadInitThunk
0x00007ffcc8e6aa68 (ntdll) RtlUserThreadStart
Transport failure! Relay allocation needs to be recreated, and NetworkManager restarted. Use NetworkManager.OnTransportFailure to be notified of such events programmatically.
UnityEngine.Debug:LogError (object)
Unity.Netcode.Transports.UTP.UnityTransport:Update () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Transports/UTP/UnityTransport.cs:899)
Shutting down due to network transport failure of UnityTransport!
UnityEngine.Debug:LogError (object)
Unity.Netcode.NetworkManager:HandleRawTransportPoll (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment1<byte>,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Core/NetworkManager.cs:1748)* *Unity.Netcode.NetworkTransport:InvokeOnTransportEvent (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment1,single) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Transports/NetworkTransport.cs:49)
Unity.Netcode.Transports.UTP.UnityTransport:Update () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Transports/UTP/UnityTransport.cs:902)

thanks a lot for this valuable info.

Hi Arnaud, I was curious if there is a ticket or link we can use to track the status of this bug in case it ever gets fixed. I imagine I’m not the only who will develop web sockets and relay in the editor and run into this.

Checking again if this issue is being tracked somewhere, thanks!

Arnaud, is there an existing bug tracked for this before I file a new one?