Search Unity

Bug UTP bug not connecting to any IP other then localhost.

Discussion in 'Unity Transport' started by skhan2523, May 19, 2023.

  1. skhan2523

    skhan2523

    Joined:
    May 26, 2016
    Posts:
    16
    I have started facing this problem that I am not able to connect to any IP except for 127.0.0.1. Even though the server and clients are running on same machine but no success if I pass my local IP. Any idea what might be causing this issue?
     
    exe2k likes this.
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    Is your server binding on an endpoint that can be reached externally? See this question in the FAQ about which endpoint to bind to. And also this question about general connection issues.
     
    skhan2523 likes this.
  3. skhan2523

    skhan2523

    Joined:
    May 26, 2016
    Posts:
    16
    I am specifically making this for local network, and I had to
    NetworkManager.Singleton.GetComponent<UnityTransport>().SetConnectionData(GetLocalIPAddress(), (ushort)7777); 
    do this before starting the server not only 1 client on specific machine can connect to it.
     
  4. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    Ah, I see you're using Netcode for GameObjects. In this case you should look at the Unity Transport component in the inspector. Newer versions have a "Allow Remote Connections" checkbox that should be enabled if you want to connect to your server from a different machine. (In older versions, set the "Listen Server Address" field to 0.0.0.0 instead.)
     
  5. skhan2523

    skhan2523

    Joined:
    May 26, 2016
    Posts:
    16
    I manually checked the "Allow Remote Connections" and server showed the localIp of the machine. even then client was not able to connect. So like I mentioned above, using SetConnectionData before starting server worked.