How To Configure a TF2 Video Replay Server

Question

How do I setup a replay server?

Answer

For a non-technical overview of the replay feature, you can view the press release here.

At its core, Replay is an extension of SourceTV. The feature must be enabled on the server side, and the “demo” files that are ultimately generated include the full PVS, meaning everyone’s perspective is recorded. Regular demos, on the other hand, only record the local player’s perspective.

At the beginning of the “setup” phase for a round of gameplay, the Replay system will begin recording if enabled (via the replay_enable ConVar). The round, also known as a recording session, is given a unique name based on the date and time of the recording. As the round/recording session progresses, small blocks of data are periodically published to a fileserver where they can be downloaded by clients.

Replay File Types

There are two types of files that are published:

1. Recording Session Blocks – These files are essentially compressed chunks of a demo file. When a client saves a Replay, the system figures out how many blocks it needs to download in order to play back the corresponding life. When the client goes to play back a particular Replay, the blocks are decompressed, validated, and written to one monolithic demo file for the game to play.

2. Session Info Files – Each round/recording session has one session info file, which maintain the state of all recording session blocks. The files use the extension .dmx, and are updated every time a block’s status changes. Clients download the session info file for a particular replay multiple times if all blocks are not available (e.g. if they’re still being published or not enough time has passed). Session info files also maintain a flag, indicating whether the session is currently recording or not.

There is no client-specific data in recording session blocks or session info files, since any resultant demo file contains everyone’s perspective. Each client records its own player slot information, so that watching the replay can start from the correct first-person perspective.

When a client requests to save a replay, they must download all blocks, starting from the beginning of the round. For the curious, the reason for this is that the demo files are “delta compressed” – which means that every “frame” in the demo is dependent on the previous frame. While this is not ideal, it should be noted that clients are smart about which blocks need to be downloaded, meaning that for any particular round, each block will only be downloaded once.

Publishing

There are two ways a Replay server can publish files for clients to download:

1. Local Web server – This method requires the installation of a Web server on the same machine as the game server. To publish a given file, the server will write it to a temporary location on disk, and then move (rename) it to a local path that the Web server sees. If the rename operation fails, the system will explicitly copy to the destination and delete the source file.

The advantage of this approach is that some may find it more secure, and it requires less work to configure. There are several disadvantages to consider here. The main issue is that clients downloading from the Web server may be using bandwidth and CPU needed to run the game server smoothly. This approach is also particularly costly for the game server in terms of bandwidth, since the cost is multiplied by however many clients are downloading the files. Lastly, this approach may open your server up to potential “Denial of Service” attacks if proper security measures are not taken. For faster machines with faster connections, this approach may be preferred.

2. FTP Offloading – The alternative approach requires access to a second machine, which must be running both an FTP server and a Web server. The Replay system will asynchronously offload Replay files from the game server to this second machine via FTP. The Web server must point to the same location on disk so that it can serve the uploaded files to clients.

The main advantage to this approach is that the burden of serving the Replay data is lifted off of the game server machine and put onto another machine. The bandwidth cost is minimized, since each replay block file is only streamed (uploaded) once, vs the Local Web server approach, where, for example, every single client who saves a replay for a particular round is going to download the first block file.

FTP is not a secure protocol, so caution should be taken to make sure login credentials do not become vulnerable to exposure.

Configuring Replay

The HLDS Update Tool will install three .cfg files with detailed comments in each. You will only need to worry about two of the files.

replay_local_http.cfg – Edit this file if you plan on using the “Local Web server” method described above.

replay_ftp.cfg – Edit this file if you plan on using the “FTP Offloading” method described above. Replay.cfg – Edit the bottom of this file to execute either replay_local_http.cfg or replay_ftp.cfg. This is the main configuration file for Replay and should be executed on server launch (i.e. “+exec replay.cfg”).

Regardless of which publishing method you choose for your server, you’ll need to set the following three ConVars:

  • replay_fileserver_host
  • replay_fileserver_port
  • replay_fileserver_path

These ConVars are shared with clients and are used to construct the URL’s for downloading recording session blocks and session info files.

The URL is constructed using the following as a template:

http://:< replay_fileserver_path>

So, as an example, if you have a Web server running on my.domain.com on port 80, you would set replay_fileserver_host to “my.domain.com” and replay_fileserver_port to 80. replay_fileserver_path should be set to the relative path where replay files will be published, so this would be something like “/” or “/replay”. Note that none of these ConVars should contain “http://”. You also do not want to include any slashes in your replay_fileserver_host.

If you cannot successfully point a Web browser to the URL constructed by replacing the template above with the values you have specified for the three fileserver ConVars, clients will not be able to download their Replays.

Configuring replay_local_http.cfg

You will only need to edit replay_local_fileserver_path, which is the full path for the Web server. For Apache on a Windows machine, using the replay_fileserver_* ConVars above, this path might be something like:

“C:MyWebServerhtdocsreplay”

On Linux, this might be something like:

“/path/to/my/web/server/htdocs/replay”

Configuring replay_ftp.cfg

You will need to edit the following ConVars, which are used to login and upload and clean up Replay files:
replay_fileserver_offload_hostname – The host name of your FTP server.
replay_fileserver_offload_port – The port needed to connected to your FTP server. This is usually 21.

  • replay_fileserver_offload_login – Your FTP username.
  • replay_fileserver_offload_password – Your FTP password.
  • replay_fileserver_offload_remotepath – The path on the FTP server where Replay files should be uploaded. For example, “/users/myusername/replay”

Testing Your Replay Configuration

Once you’ve edited the config files, you can test everything by start a dedicated server, making sure to include +exec replay.cfg to the command line parameters.

Once the game launches, the Replay system will run a series of self-tests using your configuration. Depending on the publishing method you chose, the system will either try to publish a temporary file to your local HTTP path or publish a file to your FTP server. At the time of this writing, your replay_fileserver_* ConVars will not be validated – you should do this yourself by filling out the template URL noted in the “Configuring Replay” section above and pointing a Web browser to that location.

Cleanup of Stale Replay Data

Replay files are considered “stale” if they were published more than replay_data_lifespan days ago. An asynchronous cleanup operation is launched in between every round, although it can be cleaned up explicitly using the replay_docleanup command.

Frequently Asked Questions

I want to run a Replay-enabled server. Where do I start? Read this document, from beginning to the end.

I’m running multiple servers on the same machine. Is there a way to specify a different directory for each server? Yes. Add -replayserverdir to each server command line. The directory name should be something like “server01” or “server02,” and not a full path.

When a client presses the F6 key, what exactly does that do? On the client side, number of kills, spawn and death ticks, dominations, etc are maintained on a per-life basis. If a life goes by and the client does not press F6, the data is thrown away. If a client does press F6, however, this data gets flagged and is saved to disk. Once the player dies (if they weren’t already dead when the pressed F6), the death tick is written and the system figures out the maximum recording session block needed to reconstruct a demo that will cover the entire life.

If no one saves a Replay for a particular round, does the data get thrown away? Yes.

Does Replay record on an empty server? No. Replay begins recording at the start of the “setup” phase and ends with each round.

If clients disconnect from my server, will they still be able to download their Replay data? Yes. Since Replay data is served on a Web server (and not on the game server itself), clients can download replays after disconnecting.

Will executing a changelevel command disrupt recording or publishing of Replay data? No.

Will shutting down my server mess up Replays? If you shut down your server using the “exit” command, it should publish any data it needs to and shut down gracefully. The “quit” command should work fine, too.

Secure connection failed, No Steam logon, or A connection to the VAC servers could not be made

Question

I am trying to connect to a secure game server, but I received the error message ‘SECURE CONNECTION FAILED’.

Common causes:

  • Connection Issues
  • Security Software
  • Background Applications
  • Third-party Anti-Cheat Applications

Answer

This issue stems from four main sources: connection issues, security software, background applications and third-party anti-cheat applications.
Connection Issues

Firewalls and Routers

If your computer is behind a router with a firewall, you must open the ports that Steam uses to connect to the Internet. Most embedded firewalls require you to open ports manually (they do not automatically learn your used ports). Routers without firewalls rarely need to have ports opened for a game client, but usually do for game servers. If you can specify ports to open, please use the ports specified in the following article: Required Ports for Steam. After making any changes to your router and firewall settings please EXIT STEAM AND RESTART before attempting to connect to a secure server.

Router Problems

Routers can cause connectivity problems, especially Wireless routers. If you have a stand-alone router and you are having connection problems, you can always bypass the router and plug your computer directly into your modem to see if the router is the problem.
If you determine that the router is the source of the issue, please follow the Using a Router with Steam guide. Dual WAN Routers are not compatible with Steam.

Internet Connectivity Issues

Check the stability and reliability of your Internet connection. An unstable connection can cause Steam to download improperly and connections to game servers time out.
There are many online tools that help you to check for problems with your connection, here are two of the most popular ones:

http://www.dslreports.com/tools
http://www.speedguide.net/analyzer.php

If you suspect that you are having a problem related to your Internet Connection, please contact your Internet Service Provider (ISP).

Security Software

Security, Firewall, and Anti-Virus Software

If you’re using Internet security, firewall or anti-virus software, make sure they are set to recognize Steam.exe and all instances of HL.exe and HL2.exe as trusted programs. Please consult your security program manuals for instructions.

Problems Directly After a Steam Update

If you have a connection problem immediately after a Steam update, it is most likely being caused by a firewall. The best solution is to go to the firewall permissions and remove all references to Steam.exe, HL.exe and HL2.exe and let them be relearned again. Just because there are existing permissions does NOT mean they are correct permissions. Every time the Steam client is updated, your firewall permissions need to be reset.

Multiple Firewalls

Never run more than one firewall program at a time while using Steam. They can conflict with each other and cause many different connection problems. Examples of running multiple firewalls include:

Running the Windows firewall with your router’s firewall simultaneously, Running the Windows firewall with Zone Alarm, Tiny Personal Firewall or some other third-party firewall application, Running the Windows firewall with your motherboard’s built-in firewall (mainly an issue with nForce motherboards) After making any changes to your firewall, anti-virus or security software settings please EXIT STEAM AND RESTART before attempting to connect to a secure server. Once you have restarted you should be able to connect to VAC servers.

Peer Guardian

Peer Guardian is not compatible with Steam. Please disable Peer Guardian before launching Steam to avoid connection issues.

Background Applications – P2P, FTP and Web Server Applications

Do not run Peer-to-Peer (P2P) programs like BitTorrent, Kazaa, eMule, LimeWire or Exeem in the background. These programs can consume large portions of your bandwidth. The same is true for FTP and Webserver applications such as Apache, MySQL servers and Microsoft’s IIS services.
After exiting your Peer to Peer software please EXIT STEAM AND RESTART before attempting to connect to a secure server. Once you have restarted you should be able to connect to VAC servers.

Viruses, spyware and malware, netlimiting, anonymous IP masking programs

Connection problems can also arise if your system is infected with a virus or spyware. We strongly recommend running virus checks while you are not using Steam if you suspect there is a virus or trojan on your system. For more information, please follow the Spyware, Adware, and Viruses Interfering with Steam topic. Programs like Cybersitter, Netlimiter, X-Fire and Stegnos Anonymous Internet can also interfere with normal Steam operations. Please disable these programs before launching Steam.

Third-party Anti-Cheat Applications

Using third-party anti-cheat applications, both server and client-side, is not necessary and may result in the errors outlined above. Do not use third-party anti-cheat applications while playing on a VAC secured server.

Client dropped by server and Warning: Connection Problem

Question

I am receiving one of the error messages listed below:
WARNING : Connection Problem Client dropped by server

Answer

If you are receiving these error messages, it is most likely a network connectivity issue interfering with game traffic between your machine and the server you are playing on.

Please use the following process and custom file to troubleshoot the issue: Exit from Steam completely
Download these custom files: MasterServers.vdf & MasterServers2.vdf – If the files do not download when clicked, please right click this link and select “Save Target As…” Place it in your Steamconfig folder (You will need to overwrite the current file already in place)
Default location: C:Program FilesSteamconfig
Right click this updated file and select “Properties”
In the General tab, make sure the “Read-only” box is checked and click OK. Re-start Steam and test the issue
If the issue persists, please complete the rest of this article.

Common Causes

You are using a wireless connection or a 56K modem (these devices may not be able to accommodate the bandwidth requirements of the game)
There is a virus, a P2P program, or some other background application running on your network or on your machine which is using up the bandwidth needed to maintain your connection to the game server
There are other computers on your local network which are using up the bandwidth needed to maintain your connection to the game server. The network connection for the server you are playing on is overloaded (this may result from having inadequate bandwidth to support the players who are joining the game or from other applications being run on the server) Your rate, cl_updaterate, or cl_cmdrate settings are not configured correctly for your connection speed. There is a conflict with your router, modem and/or Internet Service Provider and Steam

Troubleshooting

Programs which May Interfere with Steam
Please check this topic and disable any listed programs that could cause this issue. Spyware, Adware, and Viruses Interfering with Steam.

Review this topic for instructions on scanning for viruses and removing malicious software from your computer.
Test your Current Network Connection. Please complete this guide and make sure to bypass any router you currently have to test the connection.

Reduce Network Traffic

Try shutting down any other machines on the network to increase the bandwidth available to the machine you are using.

Change your rate setting

These are the default rates based upon connection speed:
56K Modem: 3500 to 5000
DSL: 7500
Cable/T1: 9999

Use the rate # (where # is the rate setting for your connection) command in the in-game console to change your rate setting. The console can be accessed using the ~ key while in-game. Change your cl_updaterate setting
The default cl_updaterate is 20, setting the value to a higher number increases the download demand on your connection. Use the cl_updaterate 20 command in the in-game console (~ key) to change your cl_updaterate setting to 20. Change your cl_cmdrate setting. The default cl_cmdrate is 30, setting the cale to a higher number increases the upload demoand on your internet connection.
Use the cl_cmdrate 30 command in the in-game console (~ key) to change your cl_cmdrate setting to 30.

Bad file server is enforcing file consistency

Question

I get this error: Error: Bad file Server is enforcing file consistency.

Answer

If you are getting disconnected from servers with the following error: You have been disconnected from the server.

Reason: Bad file Server is enforcing file consistency for”.

This usually happens if you copied over some custom content from an old install or installed some custom content that doesn’t match what the server is enforcing.
You will have to delete that offending custom content if you wish to play on that server.

Not all servers have the file consistency checking enabled, you can also try another server.
You’ll want to look here for the problem file (for counter-strike as an example): C:Program FilesSteamSteamAppscounter-strikecstrike
or C:ValveSteamSteamAppscounter-strikecstrike

Since the error message tells you the file name, the fastest thing you can do is to use your operating system search to locate the file: Start > Search > Find Files or Folders. Then select “all files and folders”, select the partition or hard disk that your Steam is installed to (C: typically) and enter the name of the offending file in the “all or part of file name” area, then click on search.
If the search does NOT find the file, then this means you most likely have some corrupt data in your game cache file (GCF). To fix this, you’ll have to delete the local content for that game and re-download the content again.
Before you do that, you can also try renaming your game folder temporarily and let Steam create a totally default installation, do this by exiting from Steam, then go to (using the example from above):
C:Program FilesSteamSteamAppscounter-strikecstrike
and rename the counter-strike folder to this:
C:Program FilesSteamSteamApps~counter-strikecstrike. When you start up Steam and then click on Counter-Strike in the games menu, Steam will quickly create a default installation. Then you can go to the server where you were having the problem and see if you still get kicked.

If you still have the problem then you definitely have a bad cache GCF file and you’ll need to re-download the content.

To delete the local content, go to the game that is causing you problems, so:
Steam > Games > then right-click on “Counter-Strike” (for example) and select properties.
There in that properties panel is the “delete local content” button.

CL_FlushEntityPacket

Question
I see this message when I’m playing: ‘WARNING: CL_FlushEntityPacket

Answer
If you are getting CL_FlushEntityPacket Warnings this typically means that either:
Your internet connection or the server’s internet connection is having problems.
Your connection is overloaded, for example running a peer-to-peer filesharing application in the background.

There are other computers on your local network using your internet connection.
The server you are on has its network connection overloaded.
You are running on a wireless connection with a poor or inconsistent signal.
You have a Virus or Trojan or Internet Worm infection that is generating traffic.
You are connected to the internet using a dial-up or other low-speed connection.
You have your rate or cl_updaterate or cl_cmdrate settings too fast for your internet connection.

You can help to identify and eliminate the source of your problem by:
Shut down all unnecessary programs on your computer before playing.
Disconnect all other computers in your household to see if they are causing the problem.
Scan all computers on your home network for virus/trojan and spyware. Please see this guide for further instructions.

If you are running on a wireless network, try connecting using a direct ethernet cable and see if the problem goes away. You will probably have to disable the “Wireless Zero Configuration” service while you are playing as well.

Safe rates for dial-up connections are typically around 3500-5000, while broadband connections should be able to safely run 30000 or better. You set this in your game console (~ typically) by entering: rate

The default cl_updaterate is 20, setting the value to a higher number increases the download demand on your connection. Set this in your console: cl_updaterate 20
The default cl_cmdrate is 30, setting the cale to a higher number increases the upload demoand on your internet connection. Set this in your console: cl_cmdrate 30

HL2.EXE has stopped working

Question

Game Error: HL2.EXE has stopped working

Answer

General Troubleshooting

Game crashes can have many different causes depending on your system. The best way to determine what the issue is being caused by is to follow this guide first:

Troubleshooting Game Crashes

Windows Vista Users

There are several Hotfixes available for Vista users and Vista users with Nvidia cards. We recommend following the Windows Vista Guide in its entirety.

Anti-Virus Software

Certain anti-virus and anti-spyware software such as Norton/Symantec, AVG 7.5, Avast, Spyware Doctor and Nod32 have been confirmed to cause game crashes with Source engine games. If disabling your anti-virus and/or security software does not help, you may want to consider completely uninstalling these applications until an update is released by the anti-virus software developers that resolves these compatibility issues. More information can be found in the Troubleshooting Game Crashes FAQ topic that is linked above.

Background Applications

Graphically intense games such as Half-Life 2: Episode Two and Team Fortress 2 require a large amount of your system’s resources to run. Having background applications running while you play can often result in the game engine competing for system resources with other applications. Often times this can result in the game crashing because there is not enough system resources free for the game to utilize. Please follow the guide below for more information:

Disabling Background Applications

It is also important to make sure that your system has enough paged pool memory available. Please follow this guide for more information.

Error verifying STEAM UserID ticket

Question

I receive the error: ‘You have been disconnected from the server. Reason: Error verifying STEAM UserID ticket’ when I try to connect to a server.

Answer

Important:
If the Steam Network is down or too busy you may not be able to connect to a Game Server – to determine whether or not this may be the issue, please check the Steam Status Page – if the last update for that page is more than 20 or 30 minutes behind, there may be a Steam network outage.
Please check to see if there are other players having the same problem on the SteamPowered Forums.

If it does appear as though the Steam network is down, you must wait until the problem is resolved. If you continue to receive this error message, the issue can most likely be resolved by restarting the Steam client. If restarting Steam does not resolve the issue, please exit

Steam and delete the following files from your Steam directory:
Steam.dll
SteamUI.dll
Rename the ClientRegistry.blob

The files should be found at C:Program FilesSteam (the location on your machine will vary if you specified a different installation folder, or if you have moved your Steam installation).

If you continue to see this issue, please contact Steam Support:
Contacting VALVe Billing and Support