How to seperate LoginServer and GameServer?


Here is what i have so far. I connected UE4 with a MySql Server via Mysqlcpp connecor (works perfectly fine). I do not have any Web server (php/java).
I cooked a dedicated server and client, connection works.
The Client starts the game and is on a local map for login purpose.

What i want to do next: Connect to a LoginServer, which checks if the user and password exists in the database. If so, create a HashID or something to identify the user+session. The User should then be able to select or create a character. The Gameserver has to be notified, that a new user joins the game with the Session ID.
Then the user should be able to join the server.

The Big Question here is: How do i run a Gameserver where all the playing takes place, plus a Login/Characterscreen Server seperatley. Or at least run different maps on one machine. And how do i set up the communication? I don’t want the client to talk to the Database server directly.

I know it is a bit more complicated. Maybe there is another way to set up Login,Characterselection,Gaming in an easier way, tell me. I appriciate any helpfull replies.


After looking into Sockets i think i can use a socket to talk to the client without connecting to it via console open The next step would be to do the same with the client machine, am i right? On that level it should be possible to communicate both ways and to solve the problems above? Would be nice if someone with experience in this could confim that.

im working on a script interface based on mysql, json and php dedicated for account managing validating and all stuff like that.
MAYBE i will release it for free for ue4 users when it will be ready, if you need help setting it up yourself just contact me

you will then be able to do all account managing stuff and all stuff you need for realising a account server directly from blueprint…
you can even do direct database actions from blueprint and the script interface includes servers classes for accounting and validating

its a “safe” systems using secret tokens and ip banning

Okay first never , I mean NEVER , connect direct to the Database-Server. Its the “Road-To-Hell” , really.
Second i would try to split Logi/Game-Server like this :
Start Local-Only and connect via HTTPS to a Webserver that Wrap a Databaseserver. The Web/Databaseserver check your login and if valid sends you a session for your gameserver. Then do a simple Session-Connect-To-Server and you are fine. That is only a Scratch but maybe it give you ideas

Why you use JSON for this project ?
Dont understand it wrong , but old simple PHP Mysql would be enough

Thanks for the answer. Actually I am connecting to the database via the dedicated server and I think an extra Web Layer would make it more vulnerable. Don’t misunderstand me. This is how it goes at the moment: Client starts on an extra Offline Map where the login and password is to be entered. The Cliend sends a TCP package with the login and password (not encrypted yet) to the dedicated server. Receiving this the server asks the database server if the user and password exists. If so the Server creates a SessionID which is handed to both the cliend and the dedicated server. Then the Client connects via ‘open thegameserver_com’ to the Server. After the Connection is established the the server compares the Clients SessionID with the SessionIDs he saved earlier…

All in all it works, non the less I consider this unfinished and a bit crappy, because I think there has to be a much better way than hack the whole login code like this…

I wonder if there is some Login procedure already existing in the unreal engine other than the command ‘open …’ You mentioned to do a simple Session-Connect-To-Server. This sounds exactly like something I want to achieve.

Sorry I had misunderstood something. I thought your client would make the request to your database. But it is the game-server that establishes the connection to the database.


In this technique, you can already do it nearly without the web-server. Secure only the transmission paths between client and server, and the server and database. That should be enough as far as possible.

1 Like