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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Resolved Unity Transport failed while Unet Transport succeeded!

Discussion in 'Multiplayer' started by meetjane, Aug 24, 2022.

  1. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    Platform: windows 10 enterprise
    Unity: 2021.3.8f1c1

    Steps:
    1.Create a new project using 3D template.
    2.Add package by searching name "com.unity.netcode.gameobjects".
    3.Create an empty GameObject and add component "NetworkManager" on it.
    4.Add Player prefabs with a new 3D capsule GameObject.
    5.Select "Unity Transport" in "NetworkManager".
    6.Play the scene and click "Start Host" in "NetworkManager".

    Errors:

    upload_2022-8-24_10-36-11.png upload_2022-8-24_10-50-35.png

    Server is shutting down due to network transport start failure of UnityTransport!
    UnityEngine.Debug:LogError (object)
    Unity.Netcode.NetworkManager:StartHost () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/Core/NetworkManager.cs:1099)
    Unity.Netcode.Editor.NetworkManagerEditor:OnInspectorGUI () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Editor/NetworkManagerEditor.cs:321)
    UnityEngine.GUIUtility: ProcessEvent (int,intptr,bool&)



    Server failed to bind

    UnityEngine.Debug:LogError (object)
    Unity.Netcode.Transports.UTP.UnityTransport:ServerBindAndListen (Unity.Networking.Transport.NetworkEndPoint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/Transports/UTP/UnityTransport.cs:469)
    Unity.Netcode.Transports.UTP.UnityTransport:StartServer () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/Transports/UTP/UnityTransport.cs:1252)
    Unity.Netcode.NetworkManager:StartHost () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/Core/NetworkManager.cs:1097)
    Unity.Netcode.Editor.NetworkManagerEditor:OnInspectorGUI () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Editor/NetworkManagerEditor.cs:321)
    UnityEngine.GUIUtility: ProcessEvent (int,intptr,bool&)



    If I remove component "Unity Transport" and select "Unet Transport", then it works as expected after I click "Start Host".
    I've confirmed that the default port 7777 has never been ocupied by others.
    I've also debug in NetworkDriver.cs.In the line 973, there is a statement
    Code (CSharp):
    1. var protocolBind = s_NetworkProtocols[m_NetworkProtocolIndex].Bind(s_NetworkInterfaces[m_NetworkInterfaceIndex], ref ifEndPoint);
    2. m_InternalState[InternalStateBound] = protocolBind == 0 ? 1 : 0;
    3. return protocolBind;
    which get -1 for variable "protocolBind" after execution.

    Can someone help me out please? Thanks.
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    Could you try setting the 'Server Listen Address' setting to 0.0.0.0? Is IPv4 enabled on your local network adapter (you can check that under the advanced properties)?

    Also if you're willing to debug that deeply, the method that is taking care of binding the socket in Unity Transport is
    BaselibNetworkInterface.Bind
    (in the
    BaselibNetworkInterface.cs
    file, in the same directory as
    NetworkDriver.cs
    ). There are a few places where it can return -1, typically following a check on some
    error.code
    value. If you could log that
    error.code
    value when -1 is returned, that'd be helpful in finding out what could be causing the issue.
     
  3. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    Thx for replying.
    Setting "Server Listen Address" to 0.0.0.0 is also not working and get the same error as before.
    I can't find advanced properties for checking IPv4, would you please describe the detail step?
    Still, I've checked Ipv4 is enabled in my network adaper settings.Inputing "ipconfig" in cmd will also display my ipv4 address.
    upload_2022-8-25_9-9-17.png

    I've debugged the place BaselibNetworkInterface.Bind you memtioned, here's the result:

    Code (CSharp):
    1. Binding.Baselib_RegisteredNetwork_Endpoint_GetNetworkAddress(local, &localAddress, &error);
    This statement gets Success in error.code.

    Code (CSharp):
    1. var socket = Binding.Baselib_RegisteredNetwork_Socket_UDP_Create(
    2.        &localAddress,                
    3.        Binding.Baselib_NetworkAddress_AddressReuse.Allow,
    4.        checked((uint)configuration.sendQueueCapacity),
    5.        checked((uint)configuration.receiveQueueCapacity),
    6.        &error);
    This statement gets UnexpectedError in error.code which is -1 after converting to type int.
    The method Bind() also returned next to this.
    Code (CSharp):
    1.  if (error.code != ErrorCode.Success)
    2.       return (int)error.code == -1 ? -1 : -(int)error.code;
     
  4. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    This might appear as a weird suggestion, but could you try enabling IPv6 (it's a checkbox in the screenshot you posted), restarting your PC, and then trying again?
     
  5. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    It doesn't help as well.
    I've learnt that the fundamental implement of Unity Transport is the same as Unet Transport.Since Unet is working on my pc, I doubt if the problem is in Unity Transport itself?
     
  6. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    What do you mean by that? I don't believe Unity Transport and UNet share any code.
     
  7. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    Maybe I'm wrong? I mean the way they bind port or the windows API they use may be the same?
    If that's true, then it must be somewhere wrong in application layer of Unity Transport.
    You see, I'm trying locating the problem.
     
  8. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    I see what you mean, thank you. Yes, ultimately binding will use the same system calls in both. But I'm thinking that it's not the actual binding of the socket that might be going wrong here. In Unity Transport, the bind operation will first create the socket. And on Windows, we use registered I/O for performance, which implies allocating and registering buffers on top of creating the socket.

    I'm thinking that what may be going wrong is the initialization of the RIO mechanism (that's what the error you reported would tend to indicate). I suggested enabling IPv6 because there appears to be a dependency on that in our RIO initialization code, but otherwise I'm unfortunately a bit at a loss regarding what could be causing it to fail.
     
  9. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    Do you have any idea to test if RIO works besides Unity Transport?
    I've got another computer which is the same windows platform and Unity version as this one, but that pc works all fine.
    That's really weird.
     
  10. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    Yeah, I agree it's really weird.

    Unfortunately, besides writing a C/C++ program that initializes the RIO subsystem, I'm not sure there's much that can be done to check that it works. (If you wish to go that route, the Microsoft documentation I linked to should provide all the necessary information.)

    You may want to make a quick test in C# though and create an IPv6 UDP socket from a Unity script. That would mimic the socket we create internally to initialize the RIO subsystem. Something like:
    Code (CSharp):
    1. using System.Net.Sockets;
    2.  
    3. var s = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
     
  11. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    Here's the result of test codes in C#:
    Code (CSharp):
    1. Debug.Log($"is Socket OSSupportsIPv6:{Socket.OSSupportsIPv6}");
    2. var s = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
    3. Debug.Log($"is bound: {s.IsBound}, is connected: {s.Connected}");
    upload_2022-9-1_10-56-10.png

    Is the RIO subsystem you mentioned can only tested in C/C++ program rather than C#?
    I'm not quite familiar with that. If "yes", I'll take a try to test RIO with C/C++.
     
  12. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    I'm not aware of RIO being exposed through C# APIs, so unfortunately writing C/C++ would be the only way of testing it. But fortunately, it might not be necessary to do that here. Digging through our code, I found that if RIO fails to be initialized, we fall back to using normal sockets. So it's doubtful that RIO is the problem here.

    The unexpected error you observed seems to only be generated following an error from a socket API call. If you still wish to investigate this further, you could try tracing the socket calls. Windows provides such a mechanism, but there are other tools to do the same (here's one, although this would trace all Windows API calls, which is likely to be quite noisy).
     
  13. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    Thanks for your suggestion!
    I've used WinAPIOverride64 you recommended to trace socket calls.It seems like nothing special in the logs, no function call get any error.
    Here's the detail of logs and the whole Log file you can open in WinAPIOverride64.

    upload_2022-9-2_11-17-57.png upload_2022-9-2_11-18-43.png upload_2022-9-2_11-19-42.png
     

    Attached Files:

  14. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    And Here's the API library file I chose to monitor calls:
    ws2_32.txt
    upload_2022-9-2_11-23-32.png
     
  15. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    Thanks a lot! That's actually very helpful!

    So this does indeed look like it's an issue initializing RIO. The RIO calls are not listed here (presumably because they're made through function pointers), but the sequence of system calls would tend to indicate that the
    RIOCreateRequestQueue
    call is failing with error code
    WSAEOPNOTSUPP
    (10045, from the
    WSAGetLastError
    call).

    I've done some digging, and it seems this can occur if there are TDI filters in place. These filters are normally installed by older antivirus software. It might be worth a shot to disable your antivirus, or to update it (my understanding is that these filters are deprecated and shouldn't be used anymore).
     
    hkalterkait likes this.
  16. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    Thanks! It is the TDI filter that causes the problem!
    I've check my windows EventViewer by eventvwr.msc and found several warnings about unauthorized TDI filter being detected.It infers to the file names "LgdCatcherTdi.sys" locating at "C:\WINDOWS\system32\drivers".I realized that I've used a game accelerator called "LeiGod" several weeks ago. This driver file should belongs to it.After temporarily remove this file and reboot my system.Everything works as expected perfectly.

    Thanks for your great help sincerely!
     
  17. yourihua

    yourihua

    Joined:
    Apr 11, 2017
    Posts:
    3
    If the game I developed uses netcode, then I can’t ask every user to delete the tdi program, so how can I solve it completely?
     
  18. meetjane

    meetjane

    Joined:
    Jan 23, 2018
    Posts:
    13
    I believe the majority of players won't have problem like this, for the rest of players. Maybe give them some tips about solving network problem? Otherwise, you have to use another multiplayer framework.
     
  19. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    First of all, this problem is specific to Unity Transport, not to the entire Netcode for GameObjects framework. If you're very concerned about this issue, there are other transports you can use with the framework.

    Otherwise, I agree with @meatjam that this is unlikely to be a problem for many users. TDI filters are pretty much deprecated by Microsoft. Drivers that want to get official support for Windows are not even allowed to install them, for example.

    We've also identified a way to circumvent the issue on our end, so eventually this will not be an issue at all anymore. Unfortunately it requires modifications to core Unity networking code and at this point I'm not able to say when the fix will be available.
     
    meetjane likes this.
  20. yourihua

    yourihua

    Joined:
    Apr 11, 2017
    Posts:
    3
    First of all, thank you very much for your reply. And in our development team, most team members use game VPN tools, and we use netcode for entities, not netcode for gameobjects. So if it can be fixed, can it be as soon as possible? thank you very much.
     
    Last edited: Dec 12, 2022
  21. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    Have you experienced the issue firsthand? If so, do you know which piece of software is installing TDI filters? If we had examples of legitimate and recent software that is installing TDI filters, it would help us in prioritizing this issue.
     
  22. yourihua

    yourihua

    Joined:
    Apr 11, 2017
    Posts:
    3
    Yes, there is a high probability of encountering problems when installing the following software:
    • leigod
    • astrill
    • WeGame
    In China, there are many gamers who install these programs. And of course my colleagues.So sorry for the trouble.Thanks again.
     
  23. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    Thanks for the information! I'll add it to our internal task tracking this issue and bump the priority accordingly.
     
  24. Proportion1

    Proportion1

    Joined:
    Jan 6, 2013
    Posts:
    35
    hi, i had this same problem. the program that was bugging it out using the tdi filter stuff was networx by softperfect. works fine now heh.
     
    simon-lemay-unity likes this.
  25. c0nfig69

    c0nfig69

    Joined:
    Oct 29, 2021
    Posts:
    1
    after wasting a work day I can confirm same problem with tdi filter from FortiEDR by FortiNet. Unfortunately our company policy does not allow uninstall the antivir program.
     
    simon-lemay-unity likes this.
  26. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    Thank you for reporting back and providing more examples of software that is causing this issue. We're currently working on a fix for this. I'll report back here when I have a better idea of when it will be available. Thank you for your patience on this, I understand that it's a frustrating issue to deal with.
     
    meetjane likes this.
  27. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    221
    Finally some good news regarding this issue: the fix has been made and will be released in upcoming editor versions. The first versions with the fix will be 2021.3.22f1, 2022.2.13f1, 2023.1.0b9, and 2023.2.0a7.
     
    meetjane likes this.
  28. ChangeEternity

    ChangeEternity

    Joined:
    Mar 22, 2019
    Posts:
    2
    • Thank you very much for your answer. The problem that has been bothering me all day has been solved
     
    meetjane likes this.