Network - How to connect to a remote listening server

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 need to open a hole in your router firewall and forward the appropriate port to your server, I believe the default is UDP 7777.

Hi,
Isn’t that done automatically the first time we open the game?

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. :slight_smile:

1 Like

No, it’s on your router not your PC.

What library do you use for UPnP and NAT-PMP ?

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.

Got it working! For now, I’ve manually configured the router but will give it a look to miniupnp for integration later in the process! :slight_smile:
Thanks guys!

any chance that you can write a wiki howto for MiniUPnP?

No chance. :slight_smile:

Due:

  • I’m not very familiar with English language.
  • I’m doesn’t have much time for article writing.
  • Integration of miniUPnP into UE4 takes less time that writing article about it.

Shortly, just go into ThirdParty folder and see how Epic does this.

  1. Create folder for our new thirdparty module, named “MiniUPnP” for example.

  2. I’m split up headers and libs into separate folders “include” and “lib”. In libs im insert static lib of miniupnp. Into include insert only headers.

  3. Create miniUPnP.Build.cs. E.g. module defenition.

    using UnrealBuildTool;

    public class miniUPnP : ModuleRules
    {
    public miniUPnP(TargetInfo Target)
    {
    Type = ModuleType.External;

        string miniUPnPPath = UEBuildConfiguration.UEThirdPartyDirectory + "miniUPnP/";
    
        PublicSystemIncludePaths.Add( miniUPnPPath + "include" );
        PublicLibraryPaths.Add( miniUPnPPath + "lib");
    
        PublicAdditionalLibraries.Add("miniupnpc.lib");
    }
    

    }
    .

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:

#include "ThirdParty/miniUPnP/include/miniupnpc.h"
#include "ThirdParty/miniUPnP/include/upnpcommands.h"
#include "ThirdParty/miniUPnP/include/upnperrors.h"

For examples of use see offical miniupnp demo sources. In common:

  1. Search for all upnp-able devices in network.
  2. Make sure that it’s a router. And it’s grant access to UPnP. And port not “alredy in use”. Increase port if needed.
  3. 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.

Similiar actions for libnatpmp.

Thanks sigma for the heads-up! :slight_smile:

PS: I really wish now this could be supported internally by UE4.

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)

It’s easy you setup a BP running create server and join server nodes and pass the right parameters.

1 Like

Did Anyone find out how to do this mini UPnP integration with unreal engine, plz tell me I cant do it for my game.

How do you setup a bp to connect players globally