LAN Capabilities of BF2 Stats

Discussion in 'BF2Statistics discussion' started by Mcfids, Sep 3, 2009.

  1. Mcfids

    Mcfids New Member

    Basically, my question is what features can BF2 stats provide over a LAN only network?

    We have set up a BF2 dedicated server and BF2 statistics on our network at work which has no internet access. BF2 statistics can be accessed successfully through the web admin page and the built in "Test Config" completes without any errors. The only deviation from the install procedure was to add "" to our company DNS server to resolve it to our stats server. This enables us to bypass using the included VB scripts to start our BF2 clients and server.

    Due to no online access, the clients are limited to local single player accounts as the online accounts cannot be created offline (although I've seen gamespy login emulators mentioned in other posts). As the clients play on the server we can inspect the BF2 database and see the player names with their accumulated scores but awards and ranks are missing.

    This is what we would like from BF2 stats, which is basically an equivalent of the online stats track provided by gamespy:

    - Persistent Awards: currently awards are reset when we rejoin the server i.e. the player keeps getting the same awards

    - Persistent Ranks: these currently don't work at all as everyone stays as Private

    - Viewer: some method of viewing the stats. We have tried Battlefield 2 Stats Viewer but it times out when trying to query players.

    Can anybody clarify what BF2 stats can achieve on a LAN only environment?
  2. Thinner

    Thinner New Member

    If you loose your awards/ranks either your redirect isn't working or your webserver doesn't process .aspx files as php-code. Do a ping to and check output of h**p://your-webserver/ASP/getbackendinfo.aspx

    To view your stats use the BF2Statistics Web Interface.
  3. Mcfids

    Mcfids New Member

    I've checked that the redirect is working (resolves to - our stats web server) and the output of getbackendinfo.aspx. That correctly returns:

    H ver now
    D 0.1 1251976024
    H id kit name descr
    D 11 0 Chsht_protecta Protecta shotgun with slugs
    D 22 1 Usrif_g3a3 H&K G3
    D 33 2 USSHT_Jackhammer Jackhammer shotgun
    D 44 3 Usrif_sa80 SA-80
    D 55 4 Usrif_g36c G36C
    D 66 5 RULMG_PKM PKM
    D 77 6 USSNI_M95_Barret Barret M82A2 (.50 cal rifle)
    D 88 1 sasrif_fn2000 FN2000
    D 99 2 sasrif_mp7 MP-7
    D 111 3 sasrif_g36e G36E
    D 222 4 usrif_fnscarl FN SCAR - L
    D 333 5 sasrif_mg36 MG36
    D 444 0 eurif_fnp90 P90
    D 555 6 gbrif_l96a1 L96A1
    $ 391 $

    Had a dig around the site and found the BF2Statistics Web Interface in the downloads section. Have installed that and it lists the Top 25 players on the home page and I can drill down and see detailed stats for each player including awards, which is excellent. Still not sure why the Battlefield Stats Viewer application fails though.

    I'm surprised that the awards are listed as they repeat every game session and are therefore not persistent. That still leaves the Rank problem where everyone is still a private. I'm guessing that this is something to do with the stats server not transferring the player's current stats to the game server when that player joins. Is that possible for a single player local account to be updated by the stats server?

    Also, when using a single player local account, the player is unable to access BFHQ and any weapon unlocks he might of accrued. Is there any workaround for that apart from setting global unlocks on the server?
  4. Thinner

    Thinner New Member

    If your players are still private ingame your bf2-server can't retrieve player stats from your webserver. Set debug_enable = 1 in, play a round and have a look at the gameserver log (python/bf2/logs).

    you should see something like this

    Player Manager module initialized
    Retrieving Profile ID (J. Jonsson) via HTTP/1.1 miniclient
    URI: /ASP/getplayerid.aspx?nick=J.%20Jonsson
    Received PID data is VALID, length 25
    Creating new record for player profileId 28999948
    Will retrieve medals from GSI...
    roundMedals: {}
    Added player 255, J. Jonsson (28999948) to medal/rank checking
    Getting Stats...
    Retrieving player STATS via HTTP/1.1 miniclient
    Received STATS data is VALID, length 822
    Assembling STATS dictionary with 99 keys
    Processing STATS response for player 255, size 98.
    Key ktm-4 has value 0
    Key ktm-5 has value 0
    Key ktm-6 has value 0
    Key tcdr has value 0
    Found GSI rank 0 for player 255
    Setting GSI rank 0 for player 255
    Retrieving player AWARDS via HTTP/1.1 miniclient
    Received AWARDS data is VALID, lenght 66
    Processing AWARDS response for player 255, size 0.

    There's no workaround for using BFHQ or unlocks for offline-accounts. It's a hardcoded limit in client-exe.
  5. Mcfids

    Mcfids New Member

    Thanks for the replies Thinner, I appreciate your time.

    What's your thinking in using the debug command in Is it related to your first sentence of your last post, i.e. some sort of fix for retrieving the single player stats?

    I'm still a bit confused on how BF2 stats is supposed to be used wrt online/offline accounts. If, as you say, you can only retrieve player stats with an online account, how do you create that account if the has been redirected to a local server (via the included VB scripts)? Do you have to somehow use a existing online account created before redirection script is run? You would still need to log in with it though, which wouldn't work due to the DNS redirection.

    So currently I can view the stats and awards through BF2 Stats Web Interface but are unable to read that information back into server when a player joins so ranks and the correct awards are calculated. What can I do to get around this?
  6. Thinner

    Thinner New Member

    If a player joins a game the gameserver asks (redirected to your webserver) for an playerid for a given playername. The backend (/ASP) returns the playerid for players already in your database or creates a new playerid. After that the gameserver asks for more information about the player (awards, stats including rank, unlocks). The output of these request you will see in the gameserver logs after enabling debugging (see my last post). This is all server-side and will work for online and offline accounts.

    Your bf2-client retrieves informations about the player loggin in from too to get all informations shown in BFHQ. But this is only done for online accounts because this is hardcoded in client-exe. That's why you can't open BFHQ with an offline account and your client doesn't get any informations about unlocks. This will not effect the player stats including ranks etc. because this is done server-side.

    The login-process for online accounts is separated from the stats system and will work even if you add the redirect. But you will need an active internet-connection or an gamespy login e...

    BTW: Don't use the vbs-script, it doesn't work. Add the redirect in /etc/host (on Linux-Servers) or /system32/drivers/etc/hosts.ics (on Windows-Server and Client). Make sure there is no redirect in /system32/drivers/etc/hosts, otherwise your client or windows-server will crash, because the hosts-file is checked for a redirect, but not the hosts.ics. But this shouldn't be a problem if you use your DNS-Server.

    Check your redirect, enable debugging and send me a PM with the gameserver log. Please have a look at the buglist-thread too.
    There is a bug related to IIS-Webserver, maybe you are using this.
  7. Mcfids

    Mcfids New Member

    Thanks, Thinner, that's a lot more clearer now.

    I've PM'ed you the game server log. It's a fresh install of BF v1.5 running a co-op (with bots) server and the stats (v1.4.2) database has been emptied.

    A round was played (ViPeY was one of the few human players) and the stats web interface showed the stats successfully before another round was played.

    Looking at the log, the requested awards and stats data received from the stats server for each player is flagged as invalid data, which would explain the symptoms I've been having.

    Hope you can make sense of it. Thanks in advance.
  8. Thinner

    Thinner New Member

    Getting Stats...
    Retrieving player STATS via HTTP/1.1 miniclient
    ERROR: Received STATS data is NOT VALID, length 62
    Retrieving player AWARDS via HTTP/1.1 miniclient
    ERROR: Received AWARDS data is NOT VALID, length 78

    Please make sure you have added your gameserver-ip (or the whole subnet) to $game_hosts and $admin_hosts in /ASP/_config.php and http_backend_addr in is set to your webserver-ip.

    Do a h**p:// from your gameserver-machine and check the output. Your webserver doesn't return suitable output.

    Which webserver do you use?
  9. Mcfids

    Mcfids New Member

    Pasted "h**p://" into a browser on our games server, which failed to return anything. Tracked that down to the browser defaulting to our proxy web server so added "" to the proxy exception list in the browser (both firefox and internet explorer) and ran it again.

    This time it returned the following output, which looks correct:

    H pid asof
    D 29000071 1252493142
    H award level when first
    $ 48 $

    Tried BF2 again but still got the same invalid data error when trying to retrieve the PID, awards, etc. Just in case BF2 was somehow using the web proxy, I ran "wget.exe h**p://" to emulate BF2 retrieving the URL, i.e. not from within a browser using the web proxy exceptions. This is its output:

    --10:56:32-- h**p://
    => `getawardsinfo.aspx@pid=2900071'
    Connecting to connected!
    HTTP request sent, awaiting response... 301 Moved Permanently
    Location: h**p:// [following]
    --10:56:32-- h**p://

    => `getawardsinfo.aspx@pid=2900071'
    Connecting to connected!
    HTTP request sent, awaiting response... 200 OK
    Length: unspecified [text/html]

    0K ->

    10:56:33 (63.48 KB/s) - `getawardsinfo.aspx@pid=2900071' saved [65]

    Notice the redirect to "" that we have in place on our intranet web server (also the BF2 stats server) - I don't think this should cause any trouble. The retrieved data from wget is:

    H pid asof
    D 29000071 1252494257
    H award level when first
    $ 48 $

    As wget works ok, I suspect the web proxy is not the issue here. Any ideas? btw, we use apache for the web server.
  10. Thinner

    Thinner New Member

    Please check http_backend_addr in, it should point to your webserver too.
  11. Mcfids

    Mcfids New Member

    I've rechecked what's in on the game server; the IP address is for our web server.

    # ------------------------------------------------------------------------------
    # Backend Web Server
    # ------------------------------------------------------------------------------
    http_backend_addr = ''
    http_backend_port = 80
    http_backend_asp = '/ASP/bf2statistics.php'

    Going back to the log file I pm'd you I noticed that the invalid data coming back from the stats server had different lengths depending on the player, i.e. the length seems to reflect the correct amount of information for that player where more awards, etc = longer data. Therefore is the problem that the data is somehow being misread when it arrives at the game server?
  12. Thinner

    Thinner New Member


    Retrieving player STATS via HTTP/1.1 miniclient
    ERROR: Received STATS data is NOT VALID, length 853


    if not success:
    if g_debug: print "Retrieving player STATS via HTTP/1.1 miniclient"
    data = http_get( http_backend_addr, http_backend_port, asp_playerinfo )
    if data and data[0] == 'O':
    print "Received STATS data is VALID, length %d" % int(len(data))
    print "ERROR: Received STATS data is NOT VALID, length %d" % int(len(data))

    so i think the condition data[0] == 'O' is false.

    Do you know Wireshark? Try to sniff the network traffic.
    Or maybe add a line "print data" or at least "print data[0]" after line "data = http_get(..."
    Then look at the log.
  13. Mcfids

    Mcfids New Member

    I can see why it's falling over now but not sure how to fix it.

    As a test, I added "print data" line to when it queries the PID. This logs the following:

    Retrieving Profile ID (J. Evans) via HTTP/1.1 miniclient
    URI: /ASP/getplayerid.aspx?nick=J.%20Evans

    H pid
    D 28999995
    $ 14 $


    Received PID data is INVALID, length 37

    Notice the additional information tagged on the beginning and end of the expected data; the wireshark trace describes this extra info as "chunk size" and "end of chunked encoding" respectively. This extra info is present in all the retrieved HTML albeit different values depending on the size of the data.

    Here's the complete wireshark trace FYI:

    No. Time Source Destination Protocol Info
    3130 27.146361 HTTP HTTP/1.1 200 OK (text/html)

    Frame 3130 (480 bytes on wire, 480 bytes captured)
    Ethernet II, Src: Dell_42:42:76 (00:1e:4f:42:42:76), Dst: Dell_3a:17:6e (00:13:72:3a:17:6e)
    Internet Protocol, Src: (, Dst: (
    Transmission Control Protocol, Src Port: http (80), Dst Port: mcs-fastmail (3302), Seq: 1, Ack: 124, Len: 426
    Hypertext Transfer Protocol
    HTTP/1.1 200 OK\r\n
    Date: Thu, 10 Sep 2009 11:00:57 GMT\r\n
    Server: Apache/1.3.31 (Win32) PHP/5.2.4\r\n
    X-Powered-By: PHP/5.2.4\r\n
    Set-Cookie: PHPSESSID=7cnd2uh3qljkb7al3b88i0rea4; path=/\r\n
    Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n
    Pragma: no-cache\r\n
    Connection: close\r\n
    Transfer-Encoding: chunked\r\n
    Content-Type: text/html\r\n
    HTTP chunked response
    Data chunk (25 octets)
    Chunk size: 25 octets
    Data (25 bytes)
    Data: 4F0A48097069640A440932383939393933360A2409313409...
    Chunk boundary
    End of chunked encoding
    Chunk size: 0 octets
    Chunk boundary
    Line-based text data: text/html

    Frame (480 bytes):

    0000 00 13 72 3a 17 6e 00 1e 4f 42 42 76 08 00 45 00 ..r:.n..OBBv..E.
    0010 01 d2 36 01 40 00 7f 06 36 1d c0 a8 01 c8 c0 a8 ..6.@...6.......
    0020 0a ef 00 50 0c e6 8c 20 7d d2 1f 77 60 de 50 18 ...P... }..w`.P.
    0030 ff 85 cc f4 00 00 48 54 54 50 2f 31 2e 31 20 32 ......HTTP/1.1 2
    0040 30 30 20 4f 4b 0d 0a 44 61 74 65 3a 20 54 68 75 00 OK..Date: Thu
    0050 2c 20 31 30 20 53 65 70 20 32 30 30 39 20 31 31 , 10 Sep 2009 11
    0060 3a 30 30 3a 35 37 20 47 4d 54 0d 0a 53 65 72 76 :00:57 GMT..Serv
    0070 65 72 3a 20 41 70 61 63 68 65 2f 31 2e 33 2e 33 er: Apache/1.3.3
    0080 31 20 28 57 69 6e 33 32 29 20 50 48 50 2f 35 2e 1 (Win32) PHP/5.
    0090 32 2e 34 0d 0a 58 2d 50 6f 77 65 72 65 64 2d 42 2.4..X-Powered-B
    00a0 79 3a 20 50 48 50 2f 35 2e 32 2e 34 0d 0a 53 65 y: PHP/5.2.4..Se
    00b0 74 2d 43 6f 6f 6b 69 65 3a 20 50 48 50 53 45 53 t-Cookie: PHPSES
    00c0 53 49 44 3d 37 63 6e 64 32 75 68 33 71 6c 6a 6b SID=7cnd2uh3qljk
    00d0 62 37 61 6c 33 62 38 38 69 30 72 65 61 34 3b 20 b7al3b88i0rea4;
    00e0 70 61 74 68 3d 2f 0d 0a 45 78 70 69 72 65 73 3a path=/..Expires:
    00f0 20 54 68 75 2c 20 31 39 20 4e 6f 76 20 31 39 38 Thu, 19 Nov 198
    0100 31 20 30 38 3a 35 32 3a 30 30 20 47 4d 54 0d 0a 1 08:52:00 GMT..
    0110 43 61 63 68 65 2d 43 6f 6e 74 72 6f 6c 3a 20 6e Cache-Control: n
    0120 6f 2d 73 74 6f 72 65 2c 20 6e 6f 2d 63 61 63 68 o-store, no-cach
    0130 65 2c 20 6d 75 73 74 2d 72 65 76 61 6c 69 64 61 e, must-revalida
    0140 74 65 2c 20 70 6f 73 74 2d 63 68 65 63 6b 3d 30 te, post-check=0
    0150 2c 20 70 72 65 2d 63 68 65 63 6b 3d 30 0d 0a 50 , pre-check=0..P
    0160 72 61 67 6d 61 3a 20 6e 6f 2d 63 61 63 68 65 0d ragma: no-cache.
    0170 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 63 6c 6f .Connection: clo
    0180 73 65 0d 0a 54 72 61 6e 73 66 65 72 2d 45 6e 63 se..Transfer-Enc
    0190 6f 64 69 6e 67 3a 20 63 68 75 6e 6b 65 64 0d 0a oding: chunked..
    01a0 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 74 65 Content-Type: te
    01b0 78 74 2f 68 74 6d 6c 0d 0a 0d 0a 31 39 20 0d 0a xt/html....19 ..
    01c0 4f 0a 48 09 70 69 64 0a 44 09 32 38 39 39 39 39
    01d0 33 36 0a 24 09 31 34 09 24 0d 0a 30 0d 0a 0d 0a 36.$.14.$..0....

    De-chunked entity body (25 bytes):

    0000 4f 0a 48 09 70 69 64 0a 44 09 32 38 39 39 39 39
    0010 33 36 0a 24 09 31 34 09 24 36.$.14.$
  14. Thinner

    Thinner New Member

    OK, thanks. Problem identified: Transfer-Encoding: chunked

    So you have to somehow disable chunked transfer-encoding for /ASP. But i don't know how, maybe you have to disable mod_deflate or mod_gzip. Or data is chunked because there's no Content-Length specified in html-header in def http_get()

    I don't know how to assist you, because i can't reproduce the problem and don't know enough about this topic.
  15. Thinner

    Thinner New Member

    After reading many sites about chunked encoding i would suggest your proxy-server is the problem.
    Maybe environment variable proxy-sendchunked is set to minimizes resource usage by using chunked encoding.
    Setting proxy-sendcl could fix this. But imho this isn't a solution for a company proxy-server.

    Is there any way to bypass the proxy?
  16. Mcfids

    Mcfids New Member

    Thanks for your pm, Thinner, we'll try that on Monday.

    We had already put in a quick fix/hack on the stats server python files where we added a Content Length header whenever it sent out the requested data to the server (using 'print'). It seems to work as we don't get the invalid data error anymore, although we had very little time at lunch to test it fully. We'll try your one though as it's only a change to a single file.

    btw, thinner, thanks very much for all your help in solving this - it's all been very appreciated :)
  17. Mcfids

    Mcfids New Member

    Integrated your modded onto our server and it works a treat - thanks thinner.
  18. Thinner

    Thinner New Member

    Nice to hear and good luck with your LAN.


Share This Page