Howto: Correctly setup dedicated server using epic games store version

Herisio
Posts: 29
Joined: Fri Apr 03, 2020 11:58 am

Howto: Correctly setup dedicated server using epic games store version

Post by Herisio »

As requested, copied my post from reddit

Soooooo, I got a little gift for this community...

The last time I played FS on PC was probably the 2011 installment. After that I moved from PC gaming to consoles because I got tired of having to upgrade my PC all the time. I've gotten FS19 on PC during the free hand-out on Epic Games, and I was smart enough to claim a second copy because I knew i'd want to run a server someday.

After fiddling around a few hours getting it up and running properly i can finally say I've managed to tick all my requirement boxes:
  • Manage (start / stop / configure / monitor) the server through the Giants Dedicated Server management website (i.e using the dedicatedServer.exe, how GIANTS intended)
  • Automatically start the server when windows is started (i.e. after a reboot)
  • No need to have a user actively logged on the dedicated server (i.e suspended remote desktop session)
  • No need to have the Epic Games Launcher running actively, as it was eating up 90% of CPU
Anyone who's ever gone down this road can most likely relate to the issues surrounding running a dedicated server from the Epic Games version (see here or here)

Disclaimer: While this guide goes into details on how to setup a server and get it running, it does not go into details on how to configure it (with mods and the likes, as I don't know this yet)Also any port forwarding or firewall modifications are assumed to be done already, or that you have the know-how of how to do this.To continue with this guide, I expect you are at least a little tech savvy!

So, here's how I pulled it off:
  1. Install the Epic Games launcher on your server (I assume you will use the default installation location)
    Here are some optional things you can do, in order to smooth the experience of using the Epic Games Launcher over remote desktop:
    Disable Run When My Computer Starts in the Epic Games Launcher settings.
    Disable Show Free Game Notifications and Show News And Special Offer Notifications in the Epic Games Launcher settings.
  2. Install FS19 using the Epic Games launcher (I assume you will use the default installation location)
  3. Open Epic Games launcher settings, scroll down to Manage Games and expand Farming Simulator 2019. Tick the Additional Command Line Arguments box and add

    Code: Select all

    -server
  4. Launch Farming Simulator 2019 through the Epic Games launcher library.
    If you get an error message about 3D and missing drivers, you can click on No.
    If the game continues to load in a command window, close the window.
    After this, you can safely exit the Epic Games launcher.
  5. Create a folder that will hold the dedicated server stuff (i.e. C:\GIANTS Dedicated Server)
  6. Copy the following files from C:\Program Files\Epic Games\FarmingSimulator19 into the folder created in #4:
    dedicatedServer.exe
    dedicatedServer.xml
  7. Create a folder called x64 inside the folder you created in #4
  8. Inside the x64 folder, create a batch script (i.e. run.bat) with the following contents:

    Code: Select all

    @ECHO OFF
    CD "C:\Program Files\Epic Games\FarmingSimulator19"
    FarmingSimulator2019.exe -AUTH_LOGIN=xxx -AUTH_PASSWORD=xxx
    Replace xxx with your Epic Games account and password
  9. Open an elevated command prompt in the directory created in #4 and run the following commands:

    Code: Select all

    mklink /d pdlc "C:\Program Files\Epic Games\FarmingSimulator19\pdlc"  
    mklink /d web_data "C:\Program Files\Epic Games\FarmingSimulator19\web_data"
    
  10. Edit dedicatedServer.xml with a text editing tool (i.e. notepad) and make the following changes:
    Line 17:

    Code: Select all

    <game description="Farming Simulator 19" name="FarmingSimulator2019" exe="FarmingSimulator2019Game.exe">
    change this to

    Code: Select all

    <game description="Farming Simulator 19" name="FarmingSimulator2019" exe="run.bat">
    This tells the dedicatedServer.exe to run the batch file when you click Start in the management portal
    Line 6: (sort of optional)

    Code: Select all

    <password>XXXXX</password>
    change this to

    Code: Select all

    <passphrase>XXXXX</passphrase>
    If you do not do this change, the first time you run dedicatedServer.exe it will change it for you and generate a new random password.
    Line 5: (optional)

    Code: Select all

    <username>admin</username>
    Change the value of admin to whatever you want, if you want to use a different username on the management portal to authenticate
    Line 8: (optional)

    Code: Select all

    <tls port="8443" active="true">
    change this to

    Code: Select all

    <tls port="8443" active="false">
    This tells the dedicatedServer.exe to not bother hosting an HTTPS variant of the control panel.
    While from a professional point-of-view i can only applaud that they have this setting but there are a few issues with it:
    It generates a self-signed certificate and it expects a.pem and b.pem to exist as well, and I haven't found those inside the FS19 installation.
    If you do plan on using it, may I suggest getting a proper DNS hostname for your server, along with a free SSL certificate from
    LetsEncrypt.org
  11. Run dedicatedServer.exe from inside the folder created in #4
  12. Open your browser and navigate to

    Code: Select all

    http://<your server>:8080
    or

    Code: Select all

    https://<your server>:8443
    and login with the credentials specified in the dedicatedServer.xml file (see #10.2 / #10.3)
  13. Update the settings of the game server and press Save when you are done.
    The notification at the top » Game is not activated. A separate Farming Simulator 19 license is needed for each Dedicated Server. can be safely ignored :)
    If there's a notification » Game log contains errors, you can get rid of this by clearing game.log
  14. Press start.
    It may or may not say that it failed to start the server but be patient.
    After a few seconds, you should see the server start via your remote desktop session.
    If you then refresh your browser, you should see the stats of the server (i.e. CPU load, RAM usage, ...)
  15. At this point, you should be able to stop / restart / start the server using the management panel.
  16. Test your server by connecting to it with your client :)
Getting the management panel to work when windows is restarted / without an active remote desktop session

So the last thing on my list was that I wanted to be able to run (at least the management panel) automatically whenever my server got rebooted.
This way, i can easily access the management panel and start the game server if required.
In order to achieve this, I downloaded a tool that allows you to create and manage services called NSSM - The non-*censored* service manager
Feel free to use any other tool you might have at your disposal, but this is what I went with because its free and easy to use.
  • Go to their website and download the nssm 2.24-101-g897c7ad pre-release build.
  • Extract the contents of the ZIP somewhere on your hard drive.
  • Go into the extracted folder and into the win64 sub folder, to locate the nssm.exe
  • Open an elevated command prompt and run the following command:

    Code: Select all

    nssm install FS19DedicatedServer
  • This will open a small GUI that you can use to configure the service:
    • Tab Application:
      • Set Path to point to the dedicatedServer.exe using the ... button.This should automatically fill out Startup directory for you.
    • Tab Details:
      • Set Display name to GIANTS FS19 Dedicated Server
      • Optionally fill out a Description. i.e something along the lines of "This service runs the GIANTS dedicated server
    • Tab Log on
      • Use the option This account
      • In the largest box, fill out your windows account name
      • In the 2 other boxes you need to fill out your windows account password
    • Finish by clicking on Install service
  • If at this point your game server and/or the dedicatedServer is running, you should stop them.
  • In the elevated command prompt, run this command:

    Code: Select all

    nssm start FS19DedicatedServer
    It should reply with FS19DedicatedServer: START: The operation completed successfully.
  • Attempt to access the management panel again through your browser and everything should work.
  • At this point, you can log out on the server itself
  • Start the game server through the management panel
  • Happy farming \o/
It might also be a good idea to verify that the above steps have worked correctly, by actually rebooting the server machine.Once it has rebooted, you should be able to access the management panel and start the game server without having to remote connect to the server and start things manually!

Troubleshooting
  • When clicking Start, the game server refuses to start
    Please check Task Manager on the server machine and look for any EpicGameLauncher process.Kill it if it exists. But please allow some time (i.e. 30 seconds to a minute) for everything to load properly once you press start.
Update

Here's a small update from my part after running the server for a few days now...
It seems that Epic doesn't like it that much when you run a game 24/7 so after a while, the frequent checks the game does with the Epic server returned an error, which force closed the server.
To deal with this, I have enabled the "automatic restart" option under settings > miscellaneous in the dedicated server control panel.
Now, for all Epic is concerned i'm playing the game for less than 24/hrs in one go. After that, the server is relaunched, which means it also re-authenticates with them
SpruceBringstein
Posts: 3
Joined: Wed Apr 29, 2020 4:43 pm

Re: Howto: Correctly setup dedicated server using epic games store version

Post by SpruceBringstein »

Thank you for writing up this guide. I was able to follow along and get mine up and running just like this.

A few other tweaks I made after the fact:

Disable Hibernate
- Open elevated command prompt and run

Code: Select all

powercfg.exe /h off
Optimized Windows for Best Performance
- Right click on Start menu and select System
- On the left, click Advanced System Settings
- On the Advanced Tab, select the top Settings button under Performance
- On the Visual Effects Tab, select Adjust for best performance (this just makes it so if you are RDP on to the server, you aren't using up CPU to draw menus, generate thumbnails, etc)
- On the Advanced Tab, Select Background services, then click Apply
- (Optional) Fine tune or disable the Virtual memory (pagefile). I have disabled pagefile for this server and have 16GB of RAM configured. This will avoid any paging to disk and memory should not be an issue anyway. Paging would affect performance if it were to happen.
- Click OK, Click OK again

Reboot to clean up hibernate file, pagefile, and enable the most recent Background Services configuration.

Disable Sleep, Never Turn Off Hard Disk
- Control Panel, Hardware, Power Options, Edit Plan Settings
- Click change Advanced power options
- Turn off Hard Disk After: 0 minutes
- Sleep > Sleep After: Never
(Note: there's a few ways to access these settings depending on which Windows 10 feature release you are running, disable sleep or your server goes offline after 30min)

Optional: Configure Windows Updates to Notify when Windows Updates is pending a restart. And optionally configure windows updates group policies to fine tune this to avoid overnight disruptions.
Moosey
Posts: 33
Joined: Mon Oct 28, 2019 9:45 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Moosey »

Hi

What exactly do I enter in to the -AUTH_LOGIN=xxx? I can't find a separate user name since I registered on Epic through my google account so only thing I have is my email. Only thing I see is a very long unique ID. Is that it?
Herisio
Posts: 29
Joined: Fri Apr 03, 2020 11:58 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Herisio »

Moosey wrote: Thu May 21, 2020 12:21 pm Hi

What exactly do I enter in to the -AUTH_LOGIN=xxx? I can't find a separate user name since I registered on Epic through my google account so only thing I have is my email. Only thing I see is a very long unique ID. Is that it?
Have you tried it with your google email? My username is different from my e-mail too, yet I always log in using my e-mail
Moosey
Posts: 33
Joined: Mon Oct 28, 2019 9:45 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Moosey »

Yes I did but it still opens epic games launcher and as a result I can't use the webUI start/stop even with the bat file. Epic says that another istance of the game is running. As I understand it's the DedicatedServer.exe. Also I encountered a strange problem that after a while people can't connect to my server. It gets stuck on an infinite "connecting" screen and console also doesn't show that there was an attempt to connect. IP is fixed.
Herisio
Posts: 29
Joined: Fri Apr 03, 2020 11:58 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Herisio »

Moosey wrote: Thu May 21, 2020 12:59 pm Yes I did but it still opens epic games launcher and as a result I can't use the webUI start/stop even with the bat file. Epic says that another istance of the game is running. As I understand it's the DedicatedServer.exe. Also I encountered a strange problem that after a while people can't connect to my server. It gets stuck on an infinite "connecting" screen and console also doesn't show that there was an attempt to connect. IP is fixed.
Hm, well the only difference i can see here is that I manually created an epic account using my gmail address. When i attempt to "authenticate with google" when logging in, it tells me that my gmail address is linked with an existing epic account and asks me if I want to link it...

Make sure that you have completely killed off the epic games launcher, and not just minimized. (i.e right click on the icon in your task bar, click on "Exit").
Verify in your task manager that there are no instances of anything farming related running (you can always reboot the computer to be sure)

Verify that the path used in the bat file exists. (see #8)

Make sure that you've updated the dedicatedServer.xml to run the bat file and not the executable (see #10)
Moosey
Posts: 33
Joined: Mon Oct 28, 2019 9:45 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Moosey »

Ok, figured it out. For some reason it wants the epic game launcher to be running. :hmm: I just leave it open and everything works now. Start/Stop/Restart all work from webUI as intended. Gives me errors in log but works, so I'll go with that considering I got enough processing power to have EpicGL open. So onward to the next thing with the infinite connecting glitch. Thank you for such a quick response and help. :-D
Herisio
Posts: 29
Joined: Fri Apr 03, 2020 11:58 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Herisio »

Moosey wrote: Thu May 21, 2020 2:03 pm Ok, figured it out. For some reason it wants the epic game launcher to be running. :hmm: I just leave it open and everything works now. Start/Stop/Restart all work from webUI as intended. Gives me errors in log but works, so I'll go with that considering I got enough processing power to have EpicGL open. So onward to the next thing with the infinite connecting glitch. Thank you for such a quick response and help. :-D
Odd, the whole point of this guide was to be able to run the dedicated server without the epic game launcher :hmm:

Concerning your infinite connecting glitch, sounds like a routing and/or ports issue
Moosey
Posts: 33
Joined: Mon Oct 28, 2019 9:45 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Moosey »

Herisio wrote: Thu May 21, 2020 2:12 pm
Odd, the whole point of this guide was to be able to run the dedicated server without the epic game launcher :hmm:

Concerning your infinite connecting glitch, sounds like a routing and/or ports issue
I understand that, but I double checked everything twice according to your instructions with no result. Than I reinstalled everything and set it up again step by step and again no result. Only after a few attempts of experimenting on my own I accidentally left the EpicGL open and webUI buttons started working properly. Magic! Oh, and your instructions were not useless cause webUI wasn't working properly no matter what I did. Only after I followed your manual I got a result. I think it might have something to do with me using my email instead of a proper user name. That is the only difference that I can see... :hmm:

Bout the infinite connecting glitch, I'll try running with firewall off. Also I suspect my external IP might be changing, not sure though. Will monitor that.
AvantiGaming
Posts: 2
Joined: Sun May 31, 2020 12:34 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by AvantiGaming »

I assume that even if I manage to start the dedicated server on my second PC, I wont be able to play on my gaming rig with the same account?
Herisio
Posts: 29
Joined: Fri Apr 03, 2020 11:58 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Herisio »

AvantiGaming wrote: Sun May 31, 2020 12:35 am I assume that even if I manage to start the dedicated server on my second PC, I wont be able to play on my gaming rig with the same account?
Nope, you need a second copy of the game
AvantiGaming
Posts: 2
Joined: Sun May 31, 2020 12:34 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by AvantiGaming »

Herisio wrote: Sun May 31, 2020 1:08 pm
AvantiGaming wrote: Sun May 31, 2020 12:35 am I assume that even if I manage to start the dedicated server on my second PC, I wont be able to play on my gaming rig with the same account?
Nope, you need a second copy of the game
Disappointing..
Moosey
Posts: 33
Joined: Mon Oct 28, 2019 9:45 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Moosey »

Hi,

I've figured out what my connection problem was. Actually it was two different problems caused by two different mods. Both of them were prohibiting people to connect but in different ways. That's why it was difficult to figure out. So the mods were:
Added Realism For Vehicles Dynamic Dirt
Dedi Save

If you are having trouble with players unable to connect and you are using those mods, well you know what to do. :mrgreen:
Schlacksi
Posts: 3
Joined: Sun Jul 05, 2020 8:13 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Schlacksi »

Hey!

I still got some errors:
http://prntscr.com/tc2v4z

And another thing: how do i open an elevated command prompt and when i run these commands there should be new folders in the created folder right?

Edit don_apple: fixed link to image.
Herisio
Posts: 29
Joined: Fri Apr 03, 2020 11:58 am

Re: Howto: Correctly setup dedicated server using epic games store version

Post by Herisio »

Schlacksi wrote: Sun Jul 05, 2020 9:37 am Hey!

I still got some errors:
http://prntscr.com/tc2v4z

And another thing: how do i open an elevated command prompt and when i run these commands there should be new folders in the created folder right?

Edit don_apple: fixed link to image.
Hey,

That screenshot is useless, we'd need the log to determine what the errors are (if any).
As stated in my guide, it's normal that the "the log file contains errors" message will appear.
You should only worry about this if the server isn't running at all or behaves strangely.

Also, you've given out the pin code for your server through the dedi app, i suggest you change it (although i'm not exactly sure how)

To open an elevated command prompt, depends on the version of windows you're running.
Although in any version, if you open the start menu and type "cmd" or "powershell" if you want powershell, you can then right-click and select run as administrator.
In windows 10, you can also launch an elevated command prompt directly from the folder explorer, simply click on the blue file button at the top left, hover over command prompt (or powershell if that's set as the default) and in the submenu, select open as administrator.

The mklink commands from step #9 will indeed created "folders" inside the directory you've created in step #4, although they will look like folder shortcuts (with that little arrow on the icon)
Post Reply