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 When using websockets (wss), randomly getting "Could not resolve host"

Discussion in 'Relay' started by travis-TAP-3D, Jul 20, 2023.

  1. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    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 '<unique number>-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!
     
    Last edited: Jul 20, 2023
  2. arnaud_gout

    arnaud_gout

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    26
    Hey Travis, we will look into it, thanks for reaching out!
    We will get back to you soon
     
    travis-TAP-3D and travis-tap3d like this.
  3. arnaud_gout

    arnaud_gout

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    26
    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.
     
    travis-TAP-3D likes this.
  4. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    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)
    <CreateSession>d__11:MoveNext() (at Assets/Scripts/Network/SessionViewer/SessionViewerManager.cs:152)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1: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.AsyncTaskMethodBuilder`1:SetResult(Response`1)
    Unity.Services.Lobbies.Internal.<TryCatchRequest>d__20`2:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/SDK/WrappedLobbyService.cs:390)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetResult(Response`1)
    Unity.Services.Lobbies.Apis.Lobby.<CreateLobbyAsync>d__6:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Apis/LobbyApi.cs:236)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1: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.AsyncTaskMethodBuilder`1:SetResult(HttpClientResponse)
    Unity.Services.Lobbies.Http.<CreateWebRequestAsync>d__7:MoveNext() (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:138)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1: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.TaskCompletionSource`1:SetResult(HttpClientResponse)
    Unity.Services.Lobbies.Http.<>c__DisplayClass0_0:<GetAwaiter>b__0(AsyncOperation) (at ./Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/UnityWebRequestHelpers.cs:34)
    UnityEngine.AsyncOperation:InvokeCompletionEvent()
     
  5. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    Still occurring for me as of today too:

    SocketException: Could not resolve host '6220039690651203365-us-east4.relay.cloud.unity3d.com'
     
  6. arnaud_gout

    arnaud_gout

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    26
    Hey, thanks! we think this has something to do with the dns. Thanks for the report.
     
  7. arnaud_gout

    arnaud_gout

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    26
    Just if you happen to experience an issue, exactly when you encounter it, could you try the following command:
    Code (CSharp):
    1. dig xxxx-us-east4.relay.cloud.unity3d.com
    And post the result?
    We also have the possiblity that something's wrong in dotnet...
     
  8. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    358
    Instead of using dig (which is used in linux and macOS) one would need to use nslookup on Windows.
     
    arnaud_gout likes this.
  9. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    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.
     
    Last edited: Jul 25, 2023
  10. arnaud_gout

    arnaud_gout

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    26
    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?
     
  11. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    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).
     
  12. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    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.
     
  13. arnaud_gout

    arnaud_gout

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    26
    Yeah, that was my next question, you mean a webGL build, right?
     
  14. travis-tap3d

    travis-tap3d

    Joined:
    Jul 20, 2023
    Posts:
    4
    Yes when running an actual webGL build I haven’t seen the issue (yet :) but I see the issue in editor regardless of platform (when using web sockets).
     
  15. arnaud_gout

    arnaud_gout

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    26
    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!
     
  16. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    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 :D):

    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.ReceiveJob`1<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.JobStruct`1<Unity.Networking.Transport.RelayLayer.ReceiveJob`1<Unity.Networking.Transport.UnderlyingConnectionList>>.Execute(ref Unity.Networking.Transport.RelayLayer.ReceiveJob`1<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.ReceiveJob`1<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.JobStruct`1<Unity.Networking.Transport.RelayLayer.ReceiveJob`1<Unity.Networking.Transport.UnderlyingConnectionList>>.Execute(ref Unity.Networking.Transport.RelayLayer.ReceiveJob`1<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.ArraySegment`1<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.ArraySegment`1<byte>,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)
     
  17. jamesbogart1111

    jamesbogart1111

    Joined:
    Sep 8, 2023
    Posts:
    1
    thanks a lot for this valuable info.
     
  18. travis-tap3d

    travis-tap3d

    Joined:
    Jul 20, 2023
    Posts:
    4
    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.
     
  19. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    Checking again if this issue is being tracked somewhere, thanks!
     
  20. travis-TAP-3D

    travis-TAP-3D

    Joined:
    Sep 12, 2022
    Posts:
    17
    Arnaud, is there an existing bug tracked for this before I file a new one?
     
  21. FdenUijl

    FdenUijl

    Joined:
    Sep 5, 2019
    Posts:
    23
    upload_2023-10-5_12-33-41.png

    Just got the same issue, in the editor on my windows machine, hope this helps!

    Unity: 2022.3.10f
    Relay: 1.0.5
    Unity Transport 2.1.0
     
  22. Koboct-Denis

    Koboct-Denis

    Joined:
    Jul 20, 2022
    Posts:
    19
  23. travis-tap3d

    travis-tap3d

    Joined:
    Jul 20, 2023
    Posts:
    4
    I wish I could share a ticket for all of us to follow but Unity just came back after the my bug report with they are only going to “track this internally” so I have low hopes of a fix.
     
  24. Koboct-Denis

    Koboct-Denis

    Joined:
    Jul 20, 2022
    Posts:
    19
    FdenUijl likes this.