yourmnbbn / tiny-csgo-client

Tiny csgo client for connecting dedicated server
61 stars 8 forks source link

Netmessage stream parsing corrupted sometimes #2

Closed yourmnbbn closed 2 years ago

yourmnbbn commented 2 years ago

This currently occurs only when connecting to linux server. Corrupted at message CSVCMsg_CreateStringTable_t, and ruined the rest stream.

console output:

Counter-Strike: Global Offensive
Map: de_mirage
Players: 1 (11 bots) / 14 humans
Build: 8598
Server Number: 1

Receive NetMessage CSVCMsg_CmdKeyValues_t
Receive NetMessage CSVCMsg_ServerInfo_t
Receive NetMessage CNETMsg_Tick_t
Server tick:347591, host_computationtime:0, host_computationtime_std_deviation: 0, host_framestarttime_std_deviation: 0
Receive NetMessage CNETMsg_SetConVar_t

bot_autodifficulty_threshold_high 0
cash_team_win_by_defusing_bomb 2700
mp_ggtr_bomb_pts_for_upgrade 2
mp_weapons_allow_zeus 2
mp_startmoney 1000
ff_damage_reduction_bullets 0
mp_weapons_allow_typecount 2
sv_full_alltalk 1
unknown cvar 69.5
bot_quota_mode fill
mp_join_grace_time 15
cash_player_interact_with_hostage 300
mp_maxrounds 15
mp_round_restart_delay 10
mp_maxmoney 10000
cash_team_elimination_bomb_map 2700
mp_respawn_immunitytime 0
mp_roundtime_defuse 2.25
sv_talk_enemy_dead 1
mp_ggprogressive_round_restart_delay 15
mp_timelimit 0
mp_warmuptime 90
cash_team_loser_bonus 2400
mp_randomspawn_los 0
sv_vote_to_changelevel_before_match_point 1
cash_player_killed_enemy_default 200
mp_weapons_allow_map_placed 1
mp_autokick 0
sv_minrate 80000
mp_buytime 45
spec_replay_enable 1
mp_roundtime_hostage 2
mp_freezetime 5
sv_maxcmdrate 128
mp_defuser_allocation 2
mp_solid_teammates 2
ff_damage_reduction_grenade_self 0
sv_skyname sky_dust
mp_friendlyfire 1
cash_team_win_by_time_running_out_bomb 2700
spec_freeze_panel_extended_time 0
cash_player_killed_enemy_factor 0.5
ff_damage_reduction_other 0
mp_free_armor 2
mp_molotovusedelay 0
mp_limitteams 0
cash_team_terrorist_win_bomb 2700
cash_team_elimination_hostage_map_t 2000
mp_forcecamera 0
cash_team_win_by_time_running_out_hostage 2000
cash_player_bomb_planted 200
sv_maxrate 128000
cash_player_bomb_defused 200
tv_snapshotrate 64
mp_roundtime 3
cash_team_planted_bomb_but_defused 200
mp_ggtr_bomb_respawn_delay 0
think_limit 0
ff_damage_reduction_grenade 0
cash_team_elimination_hostage_map_ct 2300
cash_team_win_by_hostage_rescue 3000
bot_join_after_player 0
cash_team_loser_bonus_consecutive_rounds 0
sv_maxupdaterate 128
Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: downloadables, max_entries: 8192, user_data_size_bits: 0, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: modelprecache, max_entries: 4096, user_data_size_bits: 2, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: genericprecache, max_entries: 512, user_data_size_bits: 2, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: , max_entries: 0, user_data_size_bits: 0, flags: 0

Receive NetMessage CSVCMsg_ClassInfo_t
Got unhandle message type 58
Got unhandle message type 70
Receive NetMessage CNETMsg_PlayerAvatarData_t
Got unhandle message type 5F
Got unhandle message type 33
Got unhandle message type BF
Got unhandle message type 6F
Got unhandle message type 9F
Got unhandle message type 75
Got unhandle message type 30
Got unhandle message type 6D
Got unhandle message type 61
Got unhandle message type FF
Got unhandle message type 74
Got unhandle message type 33
Got unhandle message type 3F
Got unhandle message type CF
HexMr commented 2 years ago

Will you try to fix this error? I know you tested it on windows, but most CS: GO servers run on linux. VALVE dedicated servers also run on linux. In fact, very few servers run on Windows. I'd like to test this repository on linux. For testing purposes, I would try to run a large number of these clients at once. I think a better solution for you would be to adapt it for linux. My guess is you'll be using this on the linux servers.

yourmnbbn commented 2 years ago

Will you try to fix this error?

Maybe, I can't guarantee but I'll try to find the problem, it's weird. It may take long because I still have other things to do.

In fact, very few servers run on Windows

Not exactly, it depends.

I would try to run a large number of these clients at once

It won't work, you need to find a way to run multiple steam instance first.

My guess is you'll be using this on the linux servers

I'm not using this, implementing this just because I am interested in the project, but sadly it does not support csgo. So I've decided to make one specially for csgo.

toorisrael commented 2 years ago

Will you try to fix this error?

First of all, this problem happens only sometimes, I've made a test server only for this and it's working fine, client got active status every time. I'll try to find out why this happens on real, public servers.

For testing purposes, I would try to run a large number of these clients at once.

I'll do exactly this later today, just for test and confirmation, but at this point I think it's everything you need for authenticating players and leaving them on server.

HexMr commented 2 years ago

Maybe, I can't guarantee but I'll try to find the problem, it's weird. It may take long because I still have other things to do. - I understand, this problem is actually very strange. Not exactly, it depends. - It may be so. Nevertheless, as far as I know, about 90% of the servers in CS: GO are Linux-based servers. I wonder what someone used windows server for, since linux is a less demanding system. It won't work, you need to find a way to run multiple steam instance first. - I think it is possible to run multiple instances, e.g. using a sandbox. @toorisrael How do you plan to run so many instances of steam? I'm not using this, implementing this just because I am interested in the project, but sadly it does not support csgo. So I've decided to make one specially for csgo. - I understand.

yourmnbbn commented 2 years ago

So far I can tell in my server environment the problem will be gone as long as you use changelevel command to randomly change a map, the client would run normally without issue. It doesn't matter if you change back it will still work. After changlevel I got it working fine on both secure and insecure linux ds.

Normally the client got about ~40kb(whatever map, whatever platform) size of the first fragment stream. That's when the client works fine. The corrupt message parsing happens when client receive ~230kb size of the fragment stream, I currently think it's a malformed fragment stream.

toorisrael commented 2 years ago

When trying to run sandboxed second instance I've got instant crashes without any errors. Is it caused by trying to use the same clientport? I've tried to redefine this, but maybe I'm doing this wrong, or it's not the cause?

HexMr commented 2 years ago

Sometimes errors appear when using the sandbox. Maybe it has to do with VAC? I know that when you try to run CS and sandbox normally on the same computer, you will likely start having VAC problems in one of them. I managed to run two games on the same computer at the same time, but as far as I know, a lot of people on UnkownCheats complain about problems with the VAC system in this situation. It is possible that in this case it is similar. https://www.unknowncheats.me/forum/counterstrike-global-offensive/451202-sandboxing-csgo-patched.html https://www.unknowncheats.me/forum/counterstrike-global-offensive/203994-sandboxie-giving-vac-errors.html

toorisrael commented 2 years ago

At the stage it crashes it's not a problem with VAC, more like some networking problem.

HexMr commented 2 years ago

Strange, you managed to connect to normal CS:GO servers? I have tried to connect to several servers where vac was running. When I tried to connect I received this message "Connection refused! #Valve_Reject_Connect_From_Lobby". I tried to connect to servers running on linux.

toorisrael commented 2 years ago

Yes, it works without much problems with my test server, run through virtual machine with sandboxie. The problem is more than one instance it terminating immediately after start: image

toorisrael commented 2 years ago

Sometimes I got STEAM Validation rejected etc. at first connection, but it works after retrying, this is one more small bug to fix, but it's not important at this point. Yes, it's public, VAC secured, linux server: image

Valve_Reject_Connect_From_Lobby could be also a csgo bug, try restarting server.

EDIT: The problem was with clientport like I thought, it works fine after changing it here for second instance.

toorisrael commented 2 years ago

link I've added clientport support, command line parameters and temp fix to Steam Validation Rejected. Tested with few instances. Sometimes I got an error: Connection failed after challenge response! (it's possible this is game server firewall issue or my internet, I will check it tomorrow). EDIT: This error also has been fixed.

yourmnbbn commented 2 years ago

I received this message "Connection refused! #Valve_Reject_Connect_From_Lobby". I tried to connect to servers running on linux.

Getting #Valve_Reject_Connect_From_Lobby error it's because the client send 0 as reservation cookie, which is not the actually cookie, so the cookie validation will fail and reject our connection. Reservation cookie is a little bit tricky and I'm still working on it. For a temporary bypass you can use this on your server. If you connect to a LAN server or use LAN connection to connect to a public server you won't have this issue, server won't validate cookie in which case.

toorisrael commented 2 years ago

@yourmnbbn is there an easy way to reduce allocated memory? It takes about 280M per process, but the process uses less than 10M.

yourmnbbn commented 2 years ago

@yourmnbbn is there an easy way to reduce allocated memory? It takes about 280M per process, but the process uses less than 10M.

~300M of memory usage must have included the shared memory used by the dll. It’s acceptable when you run multiple executable module because they’re loaded once for all. But the problem is that you use sandbox to run the client, which kind of like turning the shared memory into private memory. I don’t think there would be a solution. You pretty much can’t control the memory allocation in the dll if you don’t own it.

HexMr commented 2 years ago

I noticed a strange thing. I am connected to the server, the server reads the client as "humans". I don't know why 0 is displayed in the internet tab on the server. When I right click on the server info, the client counts towards the total number of players. However, in the server finder, the client is not counted towards the number of players.

image

yourmnbbn commented 2 years ago

I noticed a strange thing. I am connected to the server, the server reads the client as "humans". I don't know why 0 is displayed in the internet tab on the server. When I right click on the server info, the client counts towards the total number of players. However, in the server finder, the client is not counted towards the number of players.

Check the state of the players, see if they are active or something else. I'm not sure if the 'connecting' and 'spawning' player will be counted, never tested. Sometimes server will force us to reconnect and change our state to connecting, unfortunately tiny client now can't handle that message. So the state will always be connecting until reconnect.

Right click information, favorite tab and almost all the 3rd-party server information tools using A2S_INFO, which count players differently. If you want to change A2S_INFO information, use this.

toorisrael commented 2 years ago

Also make sure A2S_INFO doesn't return less players than Steam API. For example if you have 3 authenticated players, but A2S_INFO returns 0, you will see 0 players in the internet tab.

HexMr commented 2 years ago

@yourmnbbn Will you try to implement this feature in your client? As for the favorites tab, I know how it works. I saw your work a long time ago, you did a very good job.

@toorisrael My tests show that steam api returns 0 players, and a2s info returns the correct number. How does it look on your server?

toorisrael commented 2 years ago

It works for me without any problems, however I don't use it on my public, real servers.

HexMr commented 2 years ago

@toorisrael So in your case, the player connected by this client is counted for the number of players in the internet tab? Would you check it for me? I am curious to see what it looks like on another server.

toorisrael commented 2 years ago

image Just a proof it works, it's not optimal to do this as it takes 300MB of RAM per account.

HexMr commented 2 years ago

@toorisrael Have you used over 21 GB of RAM for this? That's as many as 72 players. How did you get so many clients running at once? Did the sandbox handle it?

toorisrael commented 2 years ago

Actually a lot more than this, 300M is only for client :D

yourmnbbn commented 2 years ago

Will you try to implement this feature in your client?

I assume by 'this feature' you mean the A2S anonymous query. This is actually useless, this client is meant to be only for dedicated server connecting. I'm not a big fan of making a GUI for this. But the A2S query is rather simple because all the connection-less packet is naked, without any encryption and compression, if you want you can implement yourself. Valve's documentation clearly explains how each query protocol is defined.

HexMr commented 2 years ago

@yourmnbbn I meant that "Sometimes server will force us to reconnect and change our state to connecting, unfortunately tiny client now can't handle that message."

@toorisrael I don't know why it didn't work on my earlier test server, now it works on my new test server. I mean, of course, the display in the internet tab. By the way, it was a very crazy idea. How much RAM have you completely used when connecting so many clients?

toorisrael commented 2 years ago

I meant that "Sometimes server will force us to reconnect and change our state to connecting, unfortunately tiny client now can't handle that message."

I think reconnecting is now supported, however I haven't tested it yet.

~35GB for 80 clients

HexMr commented 2 years ago

@toorisrael It's very crazy what you did, but it is admirable, congratulations :D

yourmnbbn commented 2 years ago

I meant that "Sometimes server will force us to reconnect and change our state to connecting, unfortunately tiny client now can't handle that message."

The latest two commits has already supported server changelevel and reconnect support. The client now will automatically reconnect when receiving those messages.

HexMr commented 2 years ago

@toorisrael How did you prevent the VAC error while running so many clients in the sandbox? I wanted to try to run as many clients as possible on one device. I was unable to do this because in the sandbox I get a VAC error very quickly and the client is disconnected from the server.

toorisrael commented 2 years ago

You need to use VAC Bypass and disable this check. Another option is just disabling VAC on server.

HexMr commented 2 years ago

@toorisrael Did you use the program by Daniel Krupinski?