Search Unity

Bug Problem with Unity Transport

Discussion in 'Game Server Hosting' started by Yaroslavych, May 31, 2023.

  1. Yaroslavych

    Yaroslavych

    Joined:
    Feb 3, 2022
    Posts:
    4
    Server failed to bind. This is usually caused by another process being bound to the same port.
    UnityEngine.Debug:LogError (object)
    Unity.Netcode.Transports.UTP.UnityTransport:ServerBindAndListen (Unity.Networking.Transport.NetworkEndPoint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Transports/UTP/UnityTransport.cs:562)
    Unity.Netcode.Transports.UTP.UnityTransport:StartServer () (at Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Transports/UTP/UnityTransport.cs:1348)
    Unity.Netcode.NetworkManager:StartHost () (at Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Core/NetworkManager.cs:962)
    RoomList:TryAddRoom (Room,string) (at Assets/Scripts/RoomList.cs:75)
    RoomListUI:ProcessData () (at Assets/Scripts/RoomListUI.cs:32)
    UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:514)


    Hello, i dont know what i have to do with this error. First i read thread where moderator gave advice to upgrade unity version where bug with TDI filters on Unity Transport was removed. I made this and at first times this error disapeared, but then cosnsole started write the same error. And the most not nunderstanable thing is that sometimes host starts(problem only on server and host) and sometimes not. I tryied turn off my antivirus, i tried start host with some delay(10 sec) but any of this options didnt helped. This thing happens only with unity transport
     
  2. jackward84

    jackward84

    Joined:
    Jan 26, 2017
    Posts:
    87
    Are you using the port that is provided to you by the serverconfig?

    Code (CSharp):
    1. public class BigRoxConnection : MonoBehaviour
    2. {
    3.     public ServerConfig ServerConfig;
    4.     public UnityTransport Transport;
    5.     [NonSerialized] public bool IsUnityServer;
    6.     async void Start()
    7.     {
    8.         try
    9.         {
    10.             await UnityServices.InitializeAsync();
    11.             Debug.Log("Initialized unity services");
    12.             ServerConfig = MultiplayService.Instance.ServerConfig;
    13.             Transport.ConnectionData.Address = "0.0.0.0";
    14.             Transport.ConnectionData.ServerListenAddress = "0.0.0.0";
    15.             Transport.ConnectionData.Port = ServerConfig.Port;
    16.             IsUnityServer = true;
    17.             Debug.Log("Unity server enabled.");
    18.  
    19.         }
    20.         catch (InvalidOperationException)
    21.         {
    22.             Debug.Log("I am not a unity server.");
    23.         }
    24.     }
    25. }
     
  3. Yaroslavych

    Yaroslavych

    Joined:
    Feb 3, 2022
    Posts:
    4
    No, I tried to use different random port and understood that this doesnt affect on problem. Also sometimes it works and sometimes no, usually not
     
  4. Yaroslavych

    Yaroslavych

    Joined:
    Feb 3, 2022
    Posts:
    4
    And I even created solution where I reconnect each time I get failure, because I noticed that after a few tryies it works. But Yeah, I ask Unity Technologies to help me. I tryied everything, I have seen each topic related to this problem but got nothing :( Please, If humanity has got future... So this is only because someone will help me :(:(:(
     
  5. jackward84

    jackward84

    Joined:
    Jan 26, 2017
    Posts:
    87
    Well if you are not using the port supplied to you in your allocation then it will not work. You cannot just use a static port number.

    Code (CSharp):
    1. ServerConfig = MultiplayService.Instance.ServerConfig;
    2. var port = ServerConfig.Port;  // <--- this is the port you should use for your server
    This is in the example I gave you before. You must set this port before starting your server (ie: StartHost/StartServer).