Portal Knights

Portal Knights

View Stats:
 This topic has been pinned, so it's probably important
apounder505  [developer] Feb 15, 2018 @ 5:33am
IMPORTANT! - How to setup a dedicated server for Portal Knights
Setting up a dedicated server for Portal Knights enables four players to play in the same world without having to be online at the same time.

Note: Running a server on your own computer without a clear understanding of what you are doing may make your system vulnerable for attacks from outside.

Setting up a server is not easy without some technical knowledge and takes time. We don't recommend trying to setup a dedicated server if you don't have some experiencewith setting up networks.

Here’s how to configure a dedicated server for Portal Knights:

1) Copy the “dedicated_server.zip” found in the Steam folder of your Portal Knights. In order to find that folder right click on “Portal Knights” in your Steam library and select properties. Switch to the “Local Files” tab and click on “Browse Local Files…”

2) Extract the dedicated_server.zip file in the desired location.

3) Start the "pk_dedicated_server.exe" - a log file, a configuration file, and a save data folder will be created.

4) Close the "pk_dedicated_server.exe" in order to set up the config file.

5) Open the "server_config.json" file with a text editor to set up the server. ALL ENTRIES MUST BE IN ASCII OR UTF-8!

6) The following settings can be viewed or changed:
a) basicServerData
i) name: The name that your dedicated server will display.
ii) ipv4: The local network IP address of your dedicated server. The address 0.0.0.0 allows the host computer to listen to all local network traffic. You probably won't need to change this unless you're setting up your server to work on a specific network card or interface.
iii) port: The port for the dedicated server. We recommend against changing this unless your firewall/router settings require it, or if you want to run several servers on the same PC (in which case each will need a separate port).
iv) iv. saveFolderPath: This is the location where save data will be written. This needs to be changed, if you wish to run multiple server instances on the same PC.
b) universeSize: (Small/Normal/Large) The universe size for the dedicated server.
c) hideConsoleWindow: (true/false) This will hide the console window. If this option is enabled, the server can only be closed by terminating it in the task manager.
d) admins/users/guests
i) Credentials
(1) password: Choose passwords used to access your dedicated server by different user groups. There are three user groups (admin, users, and guests) which can be set up with different passwords and rights. Only give players the password for the user group rights you want them to have and keep your admin password private!
(2) canLogin: (true/false) Defines whether a particular user group can log in.
(3) canKickPlayers: (true/false) Defines whether a particular user group can kick other players from the server.
(4) canModifyWorld: (true/false) Defines whether a particular user group can mine/build blocks/props.
(5) canInteractWithLockables: Not currently functional.

7) Start the "pk_dedicated_server.exe" again to start the dedicated server with the new settings.

8) If your dedicated server is behind a router (which is usually the case), you'll need to edit your router's port forwarding settings to ensure game data is sent to your host computer. You can do this by locating your router's admin page and finding the Port Forwarding settings therein. Here you can try to add a new service (or customer service) if possible. When asked to set up the new rule, you should be prompted on what to it. You can choose whatever name you wish, but we recommend "portalknights" for simplicity. Type needs to be "UDP". For all ports (internal and external) use "16365 unless you've changed the port in the config file (in which case make sure the ports match what you've configured there). For the "output IP" or "server IP", enter your local network address which you can find by running ipconfig via the Command Prompt. If prompted for any other information, leave it alone and continue. If you're having difficulties with this process, please visit https://portforward.com/ for help. Note that unless you set a static IP for the computer that is hosting the game, the local network IP address can change (which can make port forwarding rules invalid). Refer to your specific router's documentation to determine how to set up a static IP address for your computer.

9) Send your external IP address along with a user group password to people whom you'd like to have access to the server. Note that the IP address you entered for port forwarding will NOT be your external IP address, it will be the local network IP address. To find the external IP address needed for users to join, you'll need to visit a site such as http://whatismyip.host/. Be sure to send users your IP v4 address, not IP v6 (the IP address should look like xxx.xxx.xxx.xxx -- not xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx)

In order to set up multiple servers on the same PC, use the Command Prompt arguments provided below to prepare different configurations for each one and adapt the config files for each accordingly. Start the "pk_dedicated_server.exe" - a log file, a configuration file, and a save folder will be created.

Arguments:
a. -config myConfig.json: The myConfig.json configuration file will be used to set
up the server.

i. If a file with this name does not exist a default configuration file with
this name will be created. Note: You are free to create your own name for
your configuration files, "myConfig.json" is just an example.

b. -log mylogfile.log : The log file will be written to the specified file.

Example:
pk_dedicated_server -config myOwnConfig.json -log testServer.log
Will start a dedicated server that reads its configuration from
myOwnConfig.json and will write its log output to testServer.log

Config File Format:

{
"basicServerData": {
"name": "Servername",
"ipv4": "0.0.0.0",
"port": 16365,
"saveFolderPath": "./savedata"
},
"universeSize": "Normal",
"hideConsoleWindow": false,
"admins": {
"credentials": {
"password": "admin_password_please_change"
},
"canLogin": true,
"canKickPlayers": true,
"canModifyWorld": true,
"canInteractWithLockables": true
},
"users": {
"credentials": {
"password": ""
},
"canLogin": true,
"canKickPlayers": false,
"canModifyWorld": true,
"canInteractWithLockables": true
},
"guests": {
"credentials": {
"password": ""
},
"canLogin": false,
"canKickPlayers": false,
"canModifyWorld": false,
"canInteractWithLockables": false
}
}

Copy a World to the Dedicated Server
In order to copy your world to a newly setup dedicated Server please follow these steps:
1. Open the Savepath of Portal Knights
2. The local savepath after Cloud Save: \\Steam\userdata\STEAM USER ID\374040\remote
3. Copy all files from this folder to the savedata folder of your dedicated server (for example: C:\PK Dedicated Server\savedata)
4. Start the server and enjoy

Please keep in mind that only the world is being saved on the Dedicated Server. Please also keep in mind that the Dedicated Server is NOT connected to the Steam Cloud. Any world changes are only being saved in the named savedata folder. If you wish to make a backup please copy/paste the folder regularly somewhere else.
Last edited by apounder505; Feb 15, 2018 @ 9:02am
< >
Showing 1-15 of 70 comments
Matthew Earl Feb 15, 2018 @ 12:13pm 
sigh. so no linux/unix dedicated servers? most people who want to use dedicated servers use linux. that's because the dedicated and vps space is dominated by linux, not windows. i don't know why people would want to run a server on a dedicated platform that requires overhead from a gui, crappy filesystem and licensing fees. (wine is out of the question)
Last edited by Matthew Earl; Feb 15, 2018 @ 12:13pm
Devlin Feb 15, 2018 @ 2:48pm 
No linux support for dedicated Servers? This is an essential feature if offering dedicated servers, as most will(as mentioned in the above poster's comment) want to run their DS on a linux box where it can be easily remotely monitored, and maintained.
Lazypete Feb 15, 2018 @ 3:39pm 
I just did setup a dedicated server (I would have prefered linux but its better than no dedicated at all) and I fire my steam portal knight to try my dedicated... but I have an issue... the game never asks me for the password it just tell me the password is wrong... how do I supply the password?
dustinduse Feb 15, 2018 @ 9:37pm 
So servers dont support split screen connections? Says currupt data :(
DanSilverhound Feb 15, 2018 @ 11:40pm 
whats the deal with autosave? How frequently does it happen? Just wondering what'll happen if it accidentally gets shut down, cuz i can imagine many people setting this up themselves on their own computers, and absentmindedly shutting down / restarting their computers.
Yeah, linux support at least for the dedicated server please. Was really looking forward to that, but I certainly won't add a windows box to my infrastructure.
Oscarizxc Feb 16, 2018 @ 9:48am 
"Online System Error. Failed to join the session. Game version is incompatible."

Guessing the patch needs to also include dedicated server files? -_-
Meeett Feb 16, 2018 @ 11:48am 
I was not able to import my World, and yes I did everything like in the tutorial...
There was only one island and this was a new one... Does anyone has the same problems?
Jondel Feb 16, 2018 @ 11:59am 
Originally posted by Meeett:
I was not able to import my World, and yes I did everything like in the tutorial...
There was only one island and this was a new one... Does anyone has the same problems?
I am having the same probelm, ether one new island or an empty one where I just keep falling to my death

Getting this error.
[savedata] decompression of blob 00ffffff:44485355 return an error: Dictionary mismatch
[os] CalendarTime::year( 0 ) must be at least 1900. All before is not supported by POSIX.
[os] CalendarTime::month is out of range: 0[1,12].
[os] CalendarTime::dayOfMonth is out of range: 0[1,31].
[pk_world] UniverseHeader::getPassedSecondsSinceLastPlayed failed, because of invalid lastPlayedTime.
[savedata] decompression of blob 0000ffff:44485450 return an error: Dictionary mismatch
[GameFramework] Initialize 'InitializeApplication_Step0' - #57
Last edited by Jondel; Feb 16, 2018 @ 12:15pm
Lazypete Feb 16, 2018 @ 1:43pm 
Hmmm it looks like it says the save game doesn't have a "last played date" and because of that initialiseation is failling... yeah.. sorry it doesn't help much... but maybe you can find the LastPlayed and try to set it to something in the past, but like possible past or recent past, something post-epoch.
Matthew Earl Feb 16, 2018 @ 4:21pm 
Well I got a windows server running in freebsd bhyve. At least I can keep windows out physically. It works, but now after the patch, my friends logging it are getting a mismatch version error. I updated the game in steam. Not sure where to got with this now.
Matthew Earl Feb 16, 2018 @ 4:33pm 
Ok, got the update to work. Here are the steps. Update to the newest version of Portal Knights. Extract the dedicated_server .zip from the Steam Portal Kights directory (as said above) into a new directory. Copy the autosave directory and the server_config.json from your old dedicated folder into the new one. Overwrite any files. Execute the pk_dedicated_server file in the new directory. Confirmed working.
Teddinous Feb 17, 2018 @ 4:29am 
Anyone know how to select the world to use on the dedi sever. I copied my saves over but it keeps creating a new world
Eres Feb 17, 2018 @ 8:37am 
I'm having this same issue, tried with a few savegames. Hoping for a fix soon.

Originally posted by O0Donut:
Originally posted by Meeett:
I was not able to import my World, and yes I did everything like in the tutorial...
There was only one island and this was a new one... Does anyone has the same problems?
I am having the same probelm, ether one new island or an empty one where I just keep falling to my death

Getting this error.
[savedata] decompression of blob 00ffffff:44485355 return an error: Dictionary mismatch
[os] CalendarTime::year( 0 ) must be at least 1900. All before is not supported by POSIX.
[os] CalendarTime::month is out of range: 0[1,12].
[os] CalendarTime::dayOfMonth is out of range: 0[1,31].
[pk_world] UniverseHeader::getPassedSecondsSinceLastPlayed failed, because of invalid lastPlayedTime.
[savedata] decompression of blob 0000ffff:44485450 return an error: Dictionary mismatch
[GameFramework] Initialize 'InitializeApplication_Step0' - #57
Zormac Feb 17, 2018 @ 9:59am 
They need to rework their save system. The file names only make sense to those who know what's behind them, and the current dedicated server iteration doesn't seem to.
< >
Showing 1-15 of 70 comments
Per page: 1530 50