How to set up simple online multiplayer?

I’ve been sifting through all the documentation on multiplayer all day and I’m rather confused on what I should be doing to implement multiplayer. I’ve been reading about online subsystems and client/server models and sessions and I’m not sure if these should all be used in conjuncture with each other or if each one is used for a different purpose.

Anyway, what I’m asking is for someone who knows how servers and UE4 works to help me understand what I should be doing here.

I want to be able to host a server on my computer and let my friend hundreds of miles away be able to connect to it.

I was also going to implement a server list for easy server lookup but if I have to do something like setup my own online subsystem to do that then I won’t; this is primarily a project for my friends and I to use so it’s okay if it’s rough around the edges.

Thanks.

Ok, so either no one knows how this stuff works or no one’s seen the question.
Either way, bump.

Your question is quite general. Replication should work out of the box, you don’t need ot deal with OnlineSubsystems, first make your game work just by connecting client to server

First thing you need ot understand is that there not much difference from local and multiplayer player, they are added and playercontroller for them is created and you game should handle that, so start with that. To add a player you use either CreatePlayer() function (in viewport or gameplaystatics which also work in blueprints), or input “debugcreateplayer 1” (if this still works) to console.

Now UE4 online multiplayer is based on state replication, host holds master copy of state and clients tries to sync that state and input there own data so all clients (and host) are synced, this system is good for shooters and any other games that have real time action (not just action games) but it’s overkill for turn base or games that don’t need much information to be synced (but you can do function call replication for that using system that UE4 have) or fighting games which require more controller input based replication. I never played with replication but i think as long you use dafault movment system and oyu game can handle more then 1 player it should work out of the box, so start up the server and try to connect client (remeber about port forwording):

Now setting up replication is all about deciding what should be replicated and what server should listent to, make everything sync in correct way. You need to remember that computer memory can be easily altered locally, it’s main method of hack injections, so don’t allow client to control anything then related to player, client should only do what player is allowed to do, host is ultimate authority which should be on guard of that and it should check if it’s not getting some ridicules data from client, like player teleporting somewhere.

You should conceptrate on replication, things like OnlineSubsystem are just support social services like Steam works, PSN or XBox Live you can add that later if that confuse you, but you need to create a session in order for you game to be discoverable in LAN.

If oyu want more tip say what kind of game you making

I can’t make a client connect to a server. Either I messed something up or there’s some setup I haven’t done.

Well I tried running a server from the console and having my friend connect to it (through the console) and it didn’t work. I tried moving the server to a different level to make sure he wasn’t connected and he wasn’t.

I’m basically making the turn-based strategy board game Risk in UE4. I don’t really care what I have to do to make it work right now, I’m just trying to find something that will allow me to make a server and have someone somewhere else connect to it.

P.S. I understand what replication is and I’m pretty sure I know how to use it.

If your server is behind a router you’ll need to set it up to forward port 7777 (by default) for a direct connection to work.

If you want to avoid port forwarding you could use steam, but be aware it requires seamless travel to move to new maps once players have connected.

Hello
how do I test multiplayer for steam? (Not greenlit yet).how do I know if its working or not I did setup but unable to join server, no one replied to my question so I am posting it here.

Right, forgot to mention the port forwarding. Yes, we both tried port forwarding to 7777. Still didn’t appear to work.

Okay, so how are you connecting on the console? I’ve never done it that way myself so not sure what the ‘correct’ way is in that context. And do you have any logs from the server or client? It’s possible the connection is being made then immediately dropped.

Well if you making card based game you could build up your own protocol with sockets, if you going to use UE4 replication, don’t use any movment replication, only function calls and maybe some varable replication if needed

I use the commands from this page. I’m using a packaged project so I change ‘UE4Editor.exe’ to ‘ProjectName.exe’

To start a listen server, I used ProjectName.exe MainMenu?listen -game

To connect, my friend used ProjectName.exe [my IP] -game. We also tried connect [my IP]. I don’t know if there’s supposed to be some indicator that a connection was made, and I’m not entirely sure how to do that. I think there was some command in the GameMode that fired when a player connected to the server but I forget what it was.

To anyone following this: I fixed it (in a way). I was able to get session-based multiplayer working by using Steam’s subsystem. made a cool guide on how to do this here. For session setup, I used eXI’s guide here.

I’m still not entirely sure how to run a listen server through the console or through code, but I did solve my original problem.