Hello guys,
I got a small networking prototype (small scene with few replicated moving actors).
I’ve made a development build and send it over to some friends to test multiplayer networking in UE4.
I’m running the client and the server (listening mode) and my mates are trying to connect to through console (“open MyIpAdress”). The thing is that it only works locally (LAN), doesn’t seem to work remotely (outside our LAN).
Is there anything we need to do to test remote multiplayer networking outside LAN?
You must forward port 7777 (or port you entered in DefaultEngine.ini) on you router. Not on you PC. It’s named “Port Forwarding”. You must open input port on router, then client from the Internet can connect to you. There are two technics to do that programmaticaly from you game on your PC in local network: UPnP and NAT-PMP. Better practice - use combination of technics, e.g. when you router denied access to UPnP or doen’t have this, you can try use NAT-PMP. And opposite situation. This technics in combination cover about 96% routers. Other 4%… Well… You can display instruction screen (for manual port forwarding) in your game.
MiniUPnP for UPnP, libnatpmp (from miniupnp.free.fr) for NAT-PMP. Create two additional ThirdParty for Engine… Their are small and crossplatform. Exactly what we needed.
Now i’m develope only for Windows. In this module defenition must be platform dependecies also. “For linux-based systems you must use miniupnp daemon instead client” and another things like this.
Next just add module into your game Build.cs. Include headers, for example in game session or in global *.h:
For examples of use see offical miniupnp demo sources. In common:
Search for all upnp-able devices in network.
Make sure that it’s a router. And it’s grant access to UPnP. And port not “alredy in use”. Increase port if needed.
Say router “map outside port xxx as inside port yyy for IP zzz in LAN by protocol UDP/TCP to time 0(infinity) seconds and name this hole as GameName”. Procedure SetRedirectAndTest.
In fact you can. It’s called UPnP and NAT-PMP,but you should change code to make it work. Port is opened until computer disconnects from net or router reboots or that port opened on another computer. It’s a good practice,so there is no problem on multiple computers are able to host game at different time(You can use different ports,which is even better practice)