Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Third Party Playfab Matchmaking + Mirror + Peer to Peer

Discussion in 'Multiplayer' started by Serinx, Jun 28, 2021.

  1. Serinx

    Serinx

    Joined:
    Mar 31, 2014
    Posts:
    785
    I've setup a project using Mirror for multiplayer and hooked into Playfabs matchmaking service.
    When a match is made, the players can retrieve the IP address of each other player, then one of them can host the peer-to-peer match.
    My issue is that the hosting player probably won't have their ports forwarded to be able to accept connections.

    Searching online, most people say you need to use nat punchthrough but you need to know the IP addresses.
    (Note: punchthrough doesn't work for all routers).

    I know the IP Address, but I don't know what port to use.

    I'm thinking if I can determine the port for one of the players, they can be selected as the host and everything will connect.

    I've got it working using port forwarding, but I don't want to ask all players to do that.

    Playfab has this "Workaround for Matchmaking" but it says "While this can be used to exchange IPs, it does not guarantee connectivity between the clients." which is the problem I'm having.

    Does anyone have any ideas for how I can solve this problem? Or do I just have to throw money at this and use a centralised server?

    This will be my logic for determining if someone can host a game:

    Port is forwarded?
    Yes - can be host
    No - Try uPnp

    port forwarded?
    Yes - can be host
    No - try NAT punchthrough??

    port forwarded?
    Yes - can be host
    No - can't be host :(

    Cheers for any input.
     
    Last edited: Jun 28, 2021
  2. Serinx

    Serinx

    Joined:
    Mar 31, 2014
    Posts:
    785
    After some research, it looks like what I'm trying to do is impossible without "guessing" the port number with a random series of ports and connections checks.

    All in all, it sounds like a very unreliable method of connecting clients - an introducer server seems to be required for peer to peer, although apparently NAT punchthrough only works around 80% of the time - I could let Playfab host the game servers, though the free tier isn't very friendly to developers outside the US.

    I think Photon might be my best bet as this will handle the connectivity side for me while offering a decent amount of servers and CCU for development testing.
     
  3. Thunderik

    Thunderik

    Joined:
    Apr 28, 2020
    Posts:
    26
    Serinx likes this.
  4. LaurNTU

    LaurNTU

    Joined:
    Aug 15, 2019
    Posts:
    14
    Hello @Serinx, did you solve this issue by any chance?
    I am having the same problem.
     
  5. Serinx

    Serinx

    Joined:
    Mar 31, 2014
    Posts:
    785
    @LaurNTU no unfortunately I abandoned this idea. Using the playfab servers would probably be the easiest bet if you wanted their matchmaking service.
     
  6. moonpower1

    moonpower1

    Joined:
    Dec 7, 2017
    Posts:
    7
    i had the same idea and failed to implement it . now i read few networking books and i hope to be able to solve it in future.