Search Unity

Question Looking for demo of listen server / host architecture (NAT punchthrough, relay Server)

Discussion in 'Netcode for GameObjects' started by achimmihca, Aug 11, 2022.

  1. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
    I have an open source game and want to add multiplayer features.
    I already implemented the Hello World tutorial of Netcode for GameObjects, which worked fine for me.

    Now I am evaluating how players can establish a connection.
    For my game, I don't want to depend on a third-party server. And I need a free (no cost) solution.
    Ideally, players would be able to connect to each other directly (one player acts as a host).
    If a server is needed, then players should at least be able to set up their own server.

    A possible solution is mentioned by Unity documentation: A "listen server" is hosted by one of the player's machines. To establish a connection with this host, the documentation mentions some variations:
    - Option A: Port Forwarding
    - Option B: Relay server
    - Option C: NAT Punchthrough

    Port forwarding works of course but it puts a burden on the user. I consider this a fallback if everything else fails.

    Out of the other options, I prefer NAT Punch, possibly with a Relay server as fallback.

    However, I still have some questions:
    - Are there any example projects (e.g. on GitHub) to see NAT punch and Relay server implemented with Netcode for GameObjects?
    - The Unity documentation seems to imply that this is only a matter of the selected transport. Thus, I wonder how to use multiplayer community contributions to implement NAT Punch or the Relay server approach?
    - What exactly does a relay server require? Can I configure a regular Nginx to work as Relay server for Unity or do I have to implement a dedicated application?
    - Is there maybe existing and free (no cost) relay server infrastructure that one can use for an open source game?

    Thanks for your help!
     
    Last edited: Aug 11, 2022
    shuntecoud likes this.
  2. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
    In case you want a deep dive into the concepts of decentralized peer-to-peer (p2p) communication, I recommend this paper: https://bford.info/pub/net/p2pnat/

    Question is: Is there an example of "Netcode for GameObjects" that uses a rendevous server (for NAT punch)?

    Is there maybe even public rendevous server infrastructure that can be used for open source projects?
     
  3. pradotech

    pradotech

    Joined:
    Oct 17, 2019
    Posts:
    35
    I have the exact same question. Replying here in hope that someone find this thread and maybe provide some help.
     
  4. joan_stark

    joan_stark

    Joined:
    Jul 24, 2018
    Posts:
    43
    Same case. I want a to make a full free multiplayer game, so I cannot rely on "Relay servers". Id like to use NAT punchtrough but have 0 idea on how to handle that.

    Also, in case of doing mobile games, how port stuff related works with mobile data network. You can't open ports in that case. So if use 4g or 5g for simpler games would it work out of the box?
     
    Last edited: Nov 12, 2022
  5. achimmihca

    achimmihca

    Joined:
    Feb 13, 2016
    Posts:
    283
    My open source Unity project "UltraStar Play" is now live on Kickstarter.
    If it gets funded, it would make for a nice demo app how to do multiplayer in Unity.

    In general, your backing of UltraStar Play can be seen as investment in open source solutions for Unity.
     
    mgear likes this.