Networking: Live server swap?

Is there any way to transfer server authority and connect players to a newly chosen server in case host player loosing connection?

I don’t think the engine has a Host Migration system in place yet, there are .ini settings for it, but they don’t actually get used anywhere in the source code of the engine. See here: Is it possible to set up Host Migration? - Programming & Scripting - Unreal Engine Forums

I think this is something you’d have to build in yourself, or possibly look at an external networking API like RakNet or something.

Yep for now you have to do it on your own. I did some tests with a very simple approach which might work for you.

The idea of host migration is to select a new host when the current one drops out of the game, the problem comes when you are not able to select the new host or you do not know where to connect when your current one drops. So what I did was to pre-select the best host, this will be done every time a player enters/leaves the match. Once a auxiliary host has been selected (you can implement quite a range of selection mechanisms such as a so called [two-phase commit protocol](two-phase commit protocol) to select the next usable host) you will send the connection info to all other clients which will now to whom to connect in case the current server drops out. You can also use a back-end server which could perform the selection but my previous proposal does not require such an infrastructure. The most difficult part is to rebuild the game on the new server, so when a client converts itself to a server you MUST save the data of all other clients using the FUniqueNetId to identify them (an example on how this can be done is the InactivePlayerArray of the GameMode which is used to hold the data of players that drops and connects again to the match) and the GameState.

Hope this will help you a bit in getting it working for you.

Looking for a little more on this! I still can’t find any new documentation on how this can be done.

There is no documentation on how to implement it. Networking is unique for every game - also this topic is three years old, might be better to have created a new one!

Moss gave some good instructions on how to set about implementing it. When a player logs into an online game, find a way to determine who of all current players would make the best backup host. When the networking system throws a disconnection error, the backup host creates a new game, and the other players try to connect to it automatically.

There was a GitHub repo of ShooterGame with host migration, but I don’t know who did it or where it is right now. You might be able to search for it though.

I’ve been messing around with this using his theory, just having a hard time figuring out with blueprints (I’m not a C++ guy) how to have the clients find the new session that the back up host just created. I also am having an issue where the backup host attempts to create a session from the disconnect event and the game crashes. Not sure what that’s about.

Also, I’ve been looking around for anything on GitHub and can’t find anything so far… I’ll keep checking because that would be super helpful to have an example.