Search Unity

Using ngrok with Unity Netcode

Discussion in 'Netcode for GameObjects' started by MrDiamondDog, Feb 20, 2023.

  1. MrDiamondDog

    MrDiamondDog

    Joined:
    Aug 12, 2020
    Posts:
    20
    Local multiplayer works great. I want to be able to play this with friends, so I tried using ngrok to forward 127.0.0.1:7777. When I do this and connect with the client, it says that it is an invalid IP. Any help?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,890
    127.0.0.1 is the localhost, it is a synonym for „this computer“. You cannot forward this IP.
    Check your computer‘s network interfaces for the actual IP. Most often it will start with 192.168.x.x.
    You may also have to setup port forwarding on the Internet device (router) if you do not use a relay service.
     
  3. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi @MrDiamondDog , to solve your problem you need to use either a Matchmaker or a Relay server.
    You can Unity's official Matchmaker or Relay if you want to get this set up without losing your mind aroundthe caveats of 3rd party solutions.
     
  4. snipshotmedia

    snipshotmedia

    Joined:
    Nov 13, 2023
    Posts:
    10
    Weak response man, stop trying to funnel people into the product. We literally need a way to test real world internet scenarios in a private setting without "products" slammed in our face.

    You realize if a game blows up developed under your free platform we are pretty much forced to seek your help and onboard your services anyway? I have no problem with that, but trying to scrape us when we're learning is just petty.
     
  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,890
    Easy: the host needs to set up port forwarding on the router, and ensure incoming traffic reaches the target machine (eg firewalls). Of course users who want to connect need to know the hoster‘s IP address or use a dynamic DNS service that runs a software on the host machine that keeps the DNS entry up to date with the hoster‘s IP address.

    All of this is available for free. Of course, as with so many things, „free“ doesn‘t cover the acquisition of technical prowess and the time that goes into setup and troubleshooting, as well as complicating matters on the client side too.
     
  6. Tsunamisukoto

    Tsunamisukoto

    Joined:
    Apr 21, 2023
    Posts:
    24
    After stuffing around for the first couple days with port forwarding/manual ip addresses, I can confirm that Relay and Lobby helped link players together VERY easily (and they are written in such a way that you can replace their implementation later if you so choose, but for devs purposes, their free tiers are very generous.
     
    RikuTheFuffs-U likes this.