Search Unity

Unity Transport pre.5 failing to bind port

Discussion in 'Unity Transport' started by cerestorm, Feb 5, 2022.

  1. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    I'm having issues with pre.5 and the Unity Transport. Since updating I'm getting the following errors on the StartHost() call.

    Code (CSharp):
    1. Invalid network endpoint: :7777.
    2. UnityEngine.Debug:LogError (object)
    3. Unity.Netcode.UnityTransport/ConnectionAddressData:ParseNetworkEndpoint (string,uint16) (at Library/PackageCache/com.unity.netcode.adapter.utp@1.0.0-pre.5/Runtime/UnityTransport.cs:147)
    4. Unity.Netcode.UnityTransport/ConnectionAddressData:get_ListenEndPoint () (at Library/PackageCache/com.unity.netcode.adapter.utp@1.0.0-pre.5/Runtime/UnityTransport.cs:156)
    5. Unity.Netcode.UnityTransport:StartServer () (at Library/PackageCache/com.unity.netcode.adapter.utp@1.0.0-pre.5/Runtime/UnityTransport.cs:801)
    6. Unity.Netcode.NetworkManager:StartHost () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Core/NetworkManager.cs:898)
    7. ConnectionManager:StartHost () (at Assets/Scripts/Menus/Managers/ConnectionManager.cs:20)
    8. MultiplayerSceneController:OnClickHostButton (string) (at Assets/Scripts/Menus/Controllers/MultiplayerSceneController.cs:27)
    9. UnityEngine.EventSystems.EventSystem:Update () (at /Applications/Unity/Hub/Editor/2020.3.8f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:385)
    10.  
    Code (CSharp):
    1. Server failed to bind
    2. UnityEngine.Debug:LogError (object)
    3. Unity.Netcode.UnityTransport:ServerBindAndListen (Unity.Networking.Transport.NetworkEndPoint) (at Library/PackageCache/com.unity.netcode.adapter.utp@1.0.0-pre.5/Runtime/UnityTransport.cs:315)
    4. Unity.Netcode.UnityTransport:StartServer () (at Library/PackageCache/com.unity.netcode.adapter.utp@1.0.0-pre.5/Runtime/UnityTransport.cs:801)
    5. Unity.Netcode.NetworkManager:StartHost () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Core/NetworkManager.cs:898)
    6. ConnectionManager:StartHost () (at Assets/Scripts/Menus/Managers/ConnectionManager.cs:20)
    7. MultiplayerSceneController:OnClickHostButton (string) (at Assets/Scripts/Menus/Controllers/MultiplayerSceneController.cs:27)
    8. UnityEngine.EventSystems.EventSystem:Update () (at /Applications/Unity/Hub/Editor/2020.3.8f1/Unity.app/Contents/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:385)
    9.  
    Oddly I already had pre.5 in another project and I don't recall the error, I'm getting it there too now though. Going back to the UNet transport is working so I'll go stick with that for now.

    This is running the project on a Macbook, Big Sur 11.6.3. I tried killing all processes and ran a pending OS update but no change. Anyone using pre.5 Unity transport successfully on a Mac?
     
  2. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    After trying different things without success, and checking the separate Unity Transport package could create connections on that port, which it could, I switched over to the develop branch and it's back working. It started throwing errors down the line though so I'll just stick with pre.5 and the UNet transport for now.
     
  3. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    I think the issue is that the listen address is empty. If you go under the Unity Transport component in the inspector, there's a section called 'Connection Data' where you can set the address, port, and listen address. Setting the listen address to the same as your address should go back to the previous behavior (can also set it to 0.0.0.0 to listen on all addresses).

    Note that we don't expect users to have to do this normally. Leaving the listen address empty is a supported use case. But I messed up the deserialization case here and in pre.5 it's broken (sorry!). Until the fix is released in pre.6, you can either fill the listen address manually in the inspector, or use
    SetConnectionData
    on the
    UnityTransport
    component to configure the address/port programatically.
     
  4. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    664
    Thanks Simon, that has indeed fixed the issue. :)
     
    simon-lemay-unity likes this.
  5. liambilly

    liambilly

    Joined:
    May 13, 2022
    Posts:
    154
    i tried to set the address via the code below it gave me errror
    if(!IsHost||!IsServer)return;
    IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());

    foreach (var ip in host.AddressList)
    {
    if (ip.AddressFamily==AddressFamily.InterNetwork)
    {
    transport.ConnectionData.Address=ip.ToString();
    transport.ConnectionData.Port=7777;
    print(ip);
    break;
    }

    }

    how can i go about this, bcoz i wan to avoid the build being set to only one ip address
     
  6. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    Why do you try to get the DNS entry of your own local machine? That address is always going to be 127.0.0.1.

    And what do you mean by your build being set to only one IP address? The client can only connect to a single IP address. Either you hardcode that address, or you provide a mean for your users to input one and use that.
     
    RikuTheFuffs-U likes this.