Fanatrick
Member
Hey guys,
Last few weeks I've been trying to set up everything necessary to get the online multiplayer going for my project. So far I've been able to setup a relay server that takes care of UDP hole-punching for the clients. It properly manages connection between 2 peers, but anything more fails to work.
Here's what happens:
In my experience from playing online p2p games, I recall that even though I couldn't connect to friend_A, we could still establish the connection by just joining another friend_B's lobby and still play the game together peer-to-peer.
In case I'm wrong, what if 2 players in the lobby can't hole-punch a mutual connection between them but can do so with everyone else? This never happened to us while playing games on Steam (Rocket League, No Heroes Here, Worms WMD), as we could always find at least one player that could host us all properly in a peer-to-peer game.
I'm almost certain this is not the case, but do battle-royale kind of games hole-punch each and every player? I was under the impression that each peer needs just a single global port to receive data through from any player, but so far my implementation hints that I've got something wrong.
This is what happens summed up:
(1.1.1.1:5000) A: Hosting at 1.1.1.1:5000
(2.1.1.1:6000) B: Joins by sending to (1.1.1.1:5000) A
(1.1.1.1:5000) A: Accepts by sending to (2.1.1.1:6000) B
(2.1.1.1:6000) B: Handshake with A succeeded (10/10), peer added
(Lobby players: A, B)
(3.1.1.1:7000) C: Joins by sending to (1.1.1.1:5000) A
(1.1.1.1:5000) A: Accepts by sending to (3.1.1.1:7000) C
(3.1.1.1:7000) C: Handshake with A succeeded (10/10), peer added
(Lobby players: A, B, C)
(1.1.1.1:5000) A: Broadcasts a list of players to everyone connected to it
Sends (2.1.1.1:6000) B to (3.1.1.1:7000) C
Sends (3.1.1.1:7000) C to (2.1.1.1:6000) B
(3.1.1.1:7000) C: Handshake with B failed (0/10), peer removed
(2.1.1.1:6000) B: Handshake with C failed (0/10), peer removed
Final state of the lobby:
(Lobby players A, B, C)
A can communicate with B and C on their ports, but B and C can only communicate with A
The lobby is sad.
I've been fiddling with this for days to no avail. The hosting peer basically needs to send every other peer the IP and Port of any new player that joins the lobby but apparently they can't communicate through same ports in-between them afterwards. Since my approach seems to be flawed, any suggestions as to what needs to be changed to get this to work?
Thanks in advance.
Last few weeks I've been trying to set up everything necessary to get the online multiplayer going for my project. So far I've been able to setup a relay server that takes care of UDP hole-punching for the clients. It properly manages connection between 2 peers, but anything more fails to work.
Here's what happens:
- John, Tony and Lucy want to play a deathmatch game online
- John creates a lobby and connects with Master
- Master logs his IP-PORT(J)
- Tony tries joining John's lobby, sends his IP-PORT(T) to Master
- Master sends John IP-PORT(T) and Tony IP-PORT(J)
- John and Tony send each other packets on their respective points and the connection is established
- NOW, Lucy wants to join John's lobby, connects to Master and Master sends them their IP-PORT(J/L)
- She connects with John, then John sends her Tony's IP-PORT(T) and sends Tony her IP-PORT(L)
- Lucy and Tony send each other packets on IP-PORT(T) and IP-PORT(L) respectively, but ultimately can't establish a connection
In my experience from playing online p2p games, I recall that even though I couldn't connect to friend_A, we could still establish the connection by just joining another friend_B's lobby and still play the game together peer-to-peer.
In case I'm wrong, what if 2 players in the lobby can't hole-punch a mutual connection between them but can do so with everyone else? This never happened to us while playing games on Steam (Rocket League, No Heroes Here, Worms WMD), as we could always find at least one player that could host us all properly in a peer-to-peer game.
I'm almost certain this is not the case, but do battle-royale kind of games hole-punch each and every player? I was under the impression that each peer needs just a single global port to receive data through from any player, but so far my implementation hints that I've got something wrong.
This is what happens summed up:
(1.1.1.1:5000) A: Hosting at 1.1.1.1:5000
(2.1.1.1:6000) B: Joins by sending to (1.1.1.1:5000) A
(1.1.1.1:5000) A: Accepts by sending to (2.1.1.1:6000) B
(2.1.1.1:6000) B: Handshake with A succeeded (10/10), peer added
(Lobby players: A, B)
(3.1.1.1:7000) C: Joins by sending to (1.1.1.1:5000) A
(1.1.1.1:5000) A: Accepts by sending to (3.1.1.1:7000) C
(3.1.1.1:7000) C: Handshake with A succeeded (10/10), peer added
(Lobby players: A, B, C)
(1.1.1.1:5000) A: Broadcasts a list of players to everyone connected to it
Sends (2.1.1.1:6000) B to (3.1.1.1:7000) C
Sends (3.1.1.1:7000) C to (2.1.1.1:6000) B
(3.1.1.1:7000) C: Handshake with B failed (0/10), peer removed
(2.1.1.1:6000) B: Handshake with C failed (0/10), peer removed
Final state of the lobby:
(Lobby players A, B, C)
A can communicate with B and C on their ports, but B and C can only communicate with A
The lobby is sad.
I've been fiddling with this for days to no avail. The hosting peer basically needs to send every other peer the IP and Port of any new player that joins the lobby but apparently they can't communicate through same ports in-between them afterwards. Since my approach seems to be flawed, any suggestions as to what needs to be changed to get this to work?
Thanks in advance.