Photon or other backend for peer-to-peer?

Hi All,

I am working on this two players against each other over the internet, thing, and having some trouble figuring out what options I have to do the basic networking stuff.

I want to have the two players connect directly to each other (as listenserver-client ) and gather that I either have to implement NAT Punchthrough and UPnP, or possibly use a 3rd party backend service or solution, to enable the players to get through routers and firewalls.

Now I am finding it very hard to understand if any of them actually provides what what I need.

Has anyone done this and can tell me for sure if there is one that will do this for me?

Cheers

If you’re looking for basic listen server -> client why are you trying to use a peer-to-peer back in rather than just using UE4’s built in networking? The built in networking fully supports listen servers with absolutely no problems.

I see what you mean, yes having any kind of server behind NAT is a pain especially if you don’t have access to the NAT configuration for port forwarding even then its not a good experience if all the players need to port forward their router to be able to play.

This would also mean that someone using a mobile network connection (Which is almost always NAT) won’t be able to ever host a server.

The best method for fixing this in theory would be to have a relay server in between which has public ip, sort of a proxy server, enabling both players to talk via the relay to avoid NAT punching or port forwarding, maybe that’s what photon does. It may seem cumbersome but is still a better option than having hundreds of dedicated servers just for two players on each server.
Its a interesting topic now you mention it though , I’ll ponder some more on it and post it here

cheers

Have a look at this Traversal Using Relays around NAT - Wikipedia

Iv’e had a quick look around and these guys seem to think that using relay servers introduce extra latency, which my game would be very sensitive to. (don’t understand enough yet to know if they are right though)

http://forum.unity3d.com/threads/how-can-i-use-nat-traversal-with-unet-only-for-users-that-pay.335234/

How about Steamworks? It comes with their own P2P sockets that will handle NatTraversal nicely.

Hi.

I think we have a misunderstanding here about what Photon does.

Photon is not a peer-to-peer solution, but a client-server solution. Everything that you send over Photon goes through a Photon server, either a self-hosted one or one of the Photon Cloud servers. Therefor Photon does not provide NAT Punchthrough abilities, as you simply don’t need such when using Photon. So Commander Shepard is correct, when he says that Photon works as a relay server to forward messages between clients. From our experience this setup works far better for mobile clients than p2p.

NAT-punching is enough for what you want. I’ve done it and was planning to create a plugin for it, but haven’t had the time.

Thanks a lot all for the suggestions.

I have found some ‘ready made’ NAT punch solutions, Raknet, miniupnp(NAT-PMP), pwnat, Open.NAT so that is certainly an option. I have been warned that this can get very fiddely to get to work reliably with most users so that’s why I was hoping to find a 3rd party solution that was better and that I could just ‘add’ to my project.

Interestingly, on the Steamworks wepage they say:

My concern with Steam is that I want my game to be able to connect NON-Steam players with players buying the game through other channels too and that might not be interested in joining the Steam train just to play my game. Someone suggested this could be done and is in for example Trine 2, but I don’t know if that is true or how much work that could be.

Yes I saw some people mention Hamachi and that is a cool idea at least for testing. Might be a way to try the networking before going out and renting a server.

What’s fiddly about it? There’s a reason Steam (and many others) are using it; it works in 95% of cases and in those cases that it won’t, they use a fallback method. All you need is an external server which can tell two clients about eachother so they can punch the hole.

There’s no silver bullet though.