Search Unity

Is there any solution other than relay or manual port forwarding for peer-to-peer?

Discussion in 'Netcode for GameObjects' started by gktoz, Oct 12, 2022.

  1. gktoz

    gktoz

    Joined:
    Apr 15, 2018
    Posts:
    6
    Hello, is there any solution other than relay or manual port forwarding for peer-to-peer play? I guess UDP hole punch provides that. At least for the computer. But how can I integrate this into c#? You can also send a source. Or if there is a different peer-to-peer solution, can you show a resource showing how I can integrate it and run it?

    You can say it would be better for me:

    Computer : udp hole punch method and how to use it, how to integrate it
    Mobile : xyz method and how to use it, how to integrate it
     
    PutridEx likes this.
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,005
    Options are:
    • use a relay service
    • NAT whole punching
    • UPnP router configuration (automatic port forwarding)
    • manual port forwarding
    All options besides the relay service have points of failure meaning they will not always work.

    I haven't looked into any of these options but you'll find plenty of info on this if you search for it. However, don't expect it to be a 3-steps and you're done process. You may have to implement several techniques in order to increase chances of NAT punching to work, and then you need to be prepared for it to fail regardless. Thus it's best practice have a relay server as a fall-back option.

    Note: NGO does not offer peer-to-peer networking. The term "peer to peer" refers only to networking solutions where two clients directly communicate with each other. With NGO, clients can only communicate with the server (host), and communicating with other peers on the same server requires relaying the communication through the server (host).
     
    gktoz likes this.
  3. gktoz

    gktoz

    Joined:
    Apr 15, 2018
    Posts:
    6

    Thanks for your reply and your time.

    So as if I didn't misunderstand, I can peer-to-peer play with these methods but it's not a guarantee. So, can i connect with these methods using NGO ? Should the transport part be unity transport or should it be relay transport ? Last question i guess, these methods are working on mobile platforms ?
     
    Last edited: Oct 12, 2022