How can i make a handshake between two clients using a relay server?

Maybe i didn’t make myself clear
I Have client A and Client B. They want to start a vs online match. They both use a mobile phone for it.
Escenario 1:
1-Client A start hosting a game as Listen Server
2- Client B tries to connect to client A using Client A IP address and port.

This setup works only if they are under a LAN or same wifi network. For Internet / mobile data connections this setup does not work because NAT. That’s why i need a relay server

Escenario 2

1-Client A start hosting as Listen Server and notifies Remote Server about his state.
2- Client B tries to connect to client A using Client A Ip.
3- Client B sends packet to Remote Server. Remote server grab the package and send it back to Client A
4 -Client A gets Client B package, check magic header and stuff , make the handshake and send data back to Client B through Remote Server.
5- At this point Client A and Client B are sending packages each other through Remote Server. by passing Nat.

I want to use UE4 replication solution instead of coding my own
I want to avoid any solution that require to ask the client open their ports. In mobile that is just saying goodbye to your client.
Using a Dedicated server for a 1v1 game is overkill and expensive.

Right now i have achieved the communication between A and B, but i can’t find a way that Listen-server accepts B handshake and begin the game. and makes CLient B begin the game

1 Like