Search Unity

netcode for gameobjects dont connect to server (LAN)

Discussion in 'Netcode for GameObjects' started by ximik-xim, Jun 3, 2023.

  1. ximik-xim

    ximik-xim

    Joined:
    Jul 11, 2021
    Posts:
    1
    Hello everyone. I decided to try to create a server from a computer for tests. On the router, I set up a static (LAN) IP address at the computer and forwarded the ports. On the computer in the firewall, I gave permission to transfer data over the port and to enter and exit.
    I tried to implement a connection via netcode for gameobjects on the unity 2021 version.3.16f1. In NetworkManager, I used Unity Transport in Transport, it didn't work out through it (I indicated WAN IP) to connect 2 computers. Then I used UNet Transport and it turned out to connect 2 computers through it, but along the way there were errors that I could not fix.
    Install the Unity version 2022.3.0f1, there is no UNet Transport in it (because it is outdated), and I still can't connect 2 computers through Unity Transport. I can't find the reason why 2 computers can't connect through Unity Transport.
     
    SctBrly likes this.
  2. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi @ximik-xim, are the 2 computers in LAN or on different networks? If they're in LAN, you need to use their local IP to connect. If they're in different networks (= internet), you need to use a Relay server, dedicated server with public IP, or a NAT Punchthrough mechanism.
     
  3. SirCartaux

    SirCartaux

    Joined:
    Dec 10, 2020
    Posts:
    1
    It still won't work.
     
  4. Lumpazy

    Lumpazy

    Joined:
    Apr 24, 2018
    Posts:
    45
    Any ideas ? anywhere ?
    What if there is no firewall, the lan ip is correct, it's not even just the same lan, but the same computer, and instead of localhost it's just the local ip & port (eg 192.168.1.123:7777) Still no connection.
    Any clues where to look for the problems cause ?
    Any ways to get error messages or anything that could point into the right direction ?

    It Should work. it seems to be simple, and it should be.
    So what does one do when it doesn't ?
     
  5. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    1,807
    well lets assume you used port 7777, depending on what you did, you might need 7777 in udp too.. so.. did you?
     
  6. Nyphur

    Nyphur

    Joined:
    Jan 29, 2016
    Posts:
    98
    It's still going to your router and back again, you'd need to do port forwarding on the router and open UDP on those ports and I think you still run into NAT punchthrough issues. Frankly I haven't ever found a solution for this that reliably works other than using Unity Relay.
     
  7. Lumpazy

    Lumpazy

    Joined:
    Apr 24, 2018
    Posts:
    45
    Problem Solved.. Reason unknown.
    I rewrote the connection code.
    Would be great if some errormessages came back with a ..notconnected callback. I still can not see where i went wrong before. Or maybe some exposed variabes to check ?
    Anything to make life easier, but a ... not connected.
    There can be soo many ways to go wrong, so it would be great to have some feedback inside the networkmanager

    PS : Thanks for your replys. I had thought of these too before.
    That's the thing. The problem was not within the network or the basic setup (lan ports, firewall, port forwarding) That's what i thought. Somewhere in the code i must have made a rather stupid mistake of the 'right in fron of your eyes, but invisible' category.
    But without any feedback, it's wuite hard to find out where the problem originates. Still no clue :):) but second time i made it better than b4 anyways :)